RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague

Size: px
Start display at page:

Download "RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague"

Transcription

1 course: Database Applications (NDBI026) WS2015/16 RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague

2 Schema modification Adding and deleting columns Adding and deleting constraints Changing column definition ANSI SQL-92 Joins Optimizer and Query Optimization Indexes Execution Plans Hinting M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 2

3

4 Error in application design Wrong normal form of the schema All required data can not be stored Wrongly defined constraint Customer changes his/her requirements Support for new attributes and entities Change of constraints in the real world M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 4

5 Schema and/or application logic changes represent the important part of the application life-time Data stored in the database are usually more expensive and more important than the price of the software and hardware Ability to change/modify the schema without any data loss is more important than the ability of its creating from scratch M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 5

6 Adding column to existing table ALTER TABLE tab_name ADD column_definition; Example. ALTER TABLE Person ADD Note CHARACTER VARYING(1000); ALTER TABLE Product ADD EAN NUMERIC(13) CONSTRAINT Product_U_EAN UNIQUE; M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 6

7 Dropping column in existing table It is usually necessary to transfer data somewhere before column dropping! ALTER TABLE tab_name DROP COLUMN col_name; Example ALTER TABLE Person DROP COLUMN ZipCode; M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 7

8 Adding constraint to existing table ALTER TABLE tab_name ADD constraint_definition; Example ALTER TABLE Person ADD CONSTRAINT Person_FK_Mother FOREIGN KEY(Mother) REFERENCES Person(ID) ON DELETE SET NULL; M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 8

9 Dropping unnecessary constraint in the table ALTER TABLE tab_name DROP CONSTRAINT constraint_name; Example ALTER TABLE Person DROP CONSTRAINT Person_U_Name; M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 9

10 More columns and constraint can be added in one step using statement ALTER TABLE tab_name ADD ( column_definition constraint_definition [, ] ); Example ALTER TABLE Person ADD ( Note CHARACTER VARYING(1000), CONSTRAINT Person_Chk_Age CHECK (Age>=0) ); M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 10

11 Columns can be modified using statement ALTER TABLE tab_name MODIFY ( new_incremental_column_definition [, ] ); -- Oracle ALTER TABLE tab_name ALTER COLUMN new_incremental_column_definition; -- MS SQL Example ALTER TABLE Person MODIFY ( Note CHARACTER VARYING(2000) ); Unnoticed features remain unchanged It is possible to change NULL to NOT NULL and vice versa Column width Increase the width Decrease (usually only if the column is empty) M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 11

12 M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 12

13 The ANSI SQL-92 standard introduced more types of table join in the FROM clause (semantics taken from RA) Cartesian product Equijoin Inner join Natural join Left/Right/Full outer join Previous version allowed only Comma separated list of data sources (tables and views) Each source can be followed by the alias separated by space Join conditions only in the WHERE clause M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 13

14 ANSI SQL-92 syntax Allows usage of keyword AS between data source and alias FROM Emp AS E, Dept AS D Distinguishes semantically different types of join using new keywords in the FROM clause WHERE clause remains for additional conditions (row selection) M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 14

15 X CROSS JOIN Y Cartesian product Equivalent of previous style X, Y SELECT EmpNo, Loc FROM Emp CROSS JOIN Dept; EmpNo DeptNo DeptNo Loc 20 NEW YORK 30 DALLAS EmpNo DeptNo DeptNo Loc NEW YORK DALLAS NEW YORK DALLAS M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 15

16 X NATURAL [INNER] JOIN Y Natural join over all common columns of both tables (here only DeptNo) SELECT EmpNo, Loc FROM Emp NATURAL JOIN Dept; EmpNo DeptNo DeptNo Loc 20 NEW YORK 30 DALLAS EmpNo DeptNo Loc NEW YORK M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 16

17 X [INNER] JOIN Y ON (condition) Standard join of tables, equivalent to older FROM X, Y WHERE condition X [INNER] JOIN Y USING (column [, ]) Join over equality of column values in all mentioned columns (both tables have to have defined those columns) M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 17

18 It is possible to use one of following versions instead of INNER keyword LEFT [OUTER], RIGHT [OUTER], FULL [OUTER] In case of X LEFT JOIN Y ON (condition)... Contains the result all rows from the left table (X), even if there is no corresponding row in the right table (Y) M. Kopecký Schema Modification DBI026 -DB and Query Aplikace Optimization - MFF UK (NDBI026, Lect. 2) 18

19 INNER can be replaced by one of keywords LEFT [OUTER], RIGHT [OUTER], FULL [OUTER] SELECT * FROM Emp NATURAL LEFT JOIN Dept; The result contains all Employees including those that are not assigned to any department Non-existing fields from Dept table are empty (contain NULL value) EmpNo DeptNo Loc NEW YORK M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 19

20 INNER can be replaced by one of keywords LEFT [OUTER], RIGHT [OUTER], FULL [OUTER] SELECT * FROM Emp NATURAL RIGHT JOIN Dept; The result contains all Departments including those that have no assigned Employees Non-existing fields from Emp table are empty (contain NULL value) EmpNo DeptNo Loc NEW YORK 30 DALLAS M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 20

21 INNER can be replaced by one of keywords LEFT [OUTER], RIGHT [OUTER], FULL [OUTER] SELECT * FROM Emp NATURAL FULL JOIN Dept; Combination of both left and right outer join Non-existing fields from both tables are empty (contain NULL value) EmpNo DeptNo Loc NEW YORK 30 DALLAS M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 21

22 Oracle has also its own native (proprietary) syntax for outer joins Older, only left and right, only for equality of values ANSI version is better and portable Left outer join SELECT * FROM Dept, Emp WHERE Dept.Deptno = Emp.Deptno(+); Right outer join SELECT * FROM Dept, Emp WHERE Dept.Deptno(+) = Emp.Deptno; Full outer join DOES NOT EXISTS M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 22

23 M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 23

24 Serve for speeding-up data access according to some condition in the WHERE clause Do not change neither syntax nor semantics of DML statements Unique vs. Non-unique indexes One-column vs. More-column (concatenated) indexes Clustered vs. unclustered indexes B-trees vs. Bitmaps Indexes on columns vs. on expressions Domain indexes (full-text, space, XML, ) M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 24

25 Index creation is not standardized in SQL-92 Individual RDBMS s implement them in a proprietary way It can vary Syntax Support of particular type(s) of indexes (bitmap, hash, ) Their (non)usage for given query and data content M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 25

26 Usually redundant B + -trees Values in leaves Leaves in bi-directional list to allow easy range search. Suitable for columns having high selectivity (high number of different values in the column). Concatenated indexes can combine more columns together to increase selectivity. Suitable, if the query searches rows according to values of first k columns in the index. First k-1 columns have to be restricted by equality to constant value. Not suitable, if there is no condition on first column of the index. It is usually not possible to combine more B-tree indexes. The query is evaluated using one of them (the most selective one) and other conditions have to be tested programmatically. M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 26

27 Cannot help If the percentage of corresponding rows is too high Overhead caused by reading additional blocks of the index and mainly by non-sequential access to the data blocks In queries searching for rows containing NULL values in indexed column NULL values are usually not stored in the index Can help In queries searching rows according to equality of column value to constant In queries searching rows with column value belonging to interval M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 27

28 For each possible column value is created one bitmap (bitstring) containing 1 for and only for rows with given value in the column, otherwise 0 Suitable for columns with low selectivity Bitmaps can be effectively combined from arbitrary number of indexes to increase selectivity Combination can increase the selectivity SELECT * FROM Citizen WHERE Gender= M AND State IN ( US-NY, US-WA ); Combination of three bitmaps M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 28 M N Y W A ( )=

29 Both Oracle and MS SQL creates automatically unique indexes for Primary keys The name is the same as the name of the constraint Candidate keys (UNIQUE columns) The name is the same as the name of the constraint M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 29

30 Important is to create indexes suitable for foreign key searches!!! Speeds-up the manipulation with the master table If the master row is deleted all child rows have to be found. Without the index, the engine has to do it using table full scan If the cascade delete is used the table containing hierarchy of entities, full scan has to be done for each found and deleted child recursively. Full-scan reads all blocks, even empty ones containing only already deleted rows Index range scan finds all child rows effectively Oracle used to use full table lock in case it needed to lock all children rows and there was no suitable index available. This restricts parallel access to data from more users at the same time. M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 30

31 In other cases the indexes should be created only if they substantially help to speed-up frequently used queries Each index speeds up some queries, but slows down data modification M. Kopecký Schema Modification DBI026 -DB and Query Aplikace Optimization - MFF UK (NDBI026, Lect. 2) 31

32 Indexes on columns CREATE [UNIQUE] INDEX index_name ON tab_name(column1[, column2 [, ]]); Example CREATE INDEX Person_Sn_Nm_Inx ON Person(Surname,Name); Index can be used in statement, that searches data according value of first declared column SELECT * FROM Person WHERE Surname= Drake ; M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 32

33 Indexes on columns CREATE [UNIQUE] INDEX index_name ON tab_name(column1[, column2 [, ]]); Example CREATE INDEX Person_Sn_Nm_Inx ON Person(Surname,Name); Index cannot be used in statement, that searches data according value of second declared column SELECT * FROM Person WHERE Name= Francis ; M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 33

34 It is better to declare uniqueness using PRIMARY KEY and UNIQUE constraints Not only indexes, but also constraints are defined Constraints has to be used to allow using those columns as target of foreign key(s) M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 34

35 Indexes with ordering CREATE [UNIQUE] INDEX index_name ON tab_name(column1 [{ASC DESC}] [, ]); Define ordering for each individual column Can define the resulting row ordering in index search queries Example CREATE INDEX Employee_Job_Sal_Inx ON Employee(Job, Salary DESC); M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 35

36 Bitmap Indexes (only non-unique) CREATE BITMAP INDEX index_name ON tab_name({column1 expression1}, ); Example CREATE BITMAP INDEX Teaching_Day_Inx ON Teaching(DayOfWeek); M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 36

37 CLUSTERED At most one by default the primary key If is defined Data in the table are ordered according to index (ISF). In fact, the table forms the leaves of the index tree. Other indexes points to primary key values instead of row ID s If it is not defined Data in the table are not particularly ordered (HEAP) All indexes points to row ID s NONCLUSTERED M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 37

38 create table onheap( id numeric(5) identity (100,10) constraint onheap_pk primary key NONCLUSTERED, name character varying(10) constraint onheap_u_name unique ); select object_id, name, index_id iid, type typ, type_desc from sys.indexes; object_id name iid typ type_desc category_pk 1 1 CLUSTERED category_u_name 2 2 NONCLUSTERED NULL 0 0 HEAP onheap_u_name 2 2 NONCLUSTERED onheap_pk 3 2 NONCLUSTERED M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 38

39 Equivalent of CLUSTERED in MS SQL Table ordered according to primary key, rows form leaf level of the primary key index Other indexes point to logcal ROWID s Primary key value + supposed address CREATE TABLE Person( ID VARCHAR2(11) CONSTRAINT Person_PK PRIMARY KEY, ) ORGANIZATION INDEX; M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 39

40 Index dropping ORACLE: DROP INDEX index_name; MSSQL: DROP INDEX tab_name.index_name; M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 40

41 Index information are in Oracle stored in views USER_INDEXES USER_IND_COLUMNS Index information are in MS SQL stored in views INFORMATION_SCHEMA.INDEXES M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 41

42 Use correct type of indexes for given selectivity Do not create all possible indexes over all columns and dheir combinations Slows down data actualizations Increases the amount of disk space taken M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 42

43 When developing the application use all available means in the target database For finding the best possible variant of the query Hint the optimizer only in case all other possible tries failed Optimizers have their limits Heuristics are used to find the best plan, non-promissing branches of plan space are pruned Thus, only some combinations of data access paths and table joins are taken into account M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 43

44 One query can be written in many ways The same semantics Different way to achieve the result The time spent can differ many times!!! The plan for executing given query written in given form provides the query optimizer You need Know how to find out the plan used Use the best optimizable form of the query or help the optimizer with optimization explicitely M. Kopecký Schema Modification DBI026 -DB and Query Aplikace Optimization - MFF UK (NDBI026, Lect. 2) 44

45 A (binary) tree of elementary operations Evaluated in post-order manner, the root operation provides complete result In leaves are data access paths to sources Table ROWID direct access Index UNIQUE SCAN Index RANGE SCAN Table FULL SCAN In inner nodes Accesses to table rows according to index-provided addresses Joins (nested loops, MERGE JOIN, HASH JOIN) Data sorting operations Filters for remaining predicates M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 45

46 In Oracle Older RULE BASED optimization (RBO) Derives the plan from the statement syntax and from available indexes Newer COST BASED optimization (CBO) Oracle 8+, recommended for better results Based on metadata available/computed for tables and columns, computes the overall cost of the plan according to estimated usage of resources for operation execution (amount of time, space, ordering, data block accesses, ) Can distinguish the effectiveness of two different index range scans as well as the cost of execution for different constant used in the query M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 46

47 The cost of data access in descending order Table Full-scan All data blocks of the table are read one by one. Conditions are checked programmatically for each row. Can be optimal if the number of matching rows is large enough. Index-Range-Scan The interval is found out in the index. Other conditions are checked programmatically. Unique-Index-Scan The at most one suitable row is found out using search in the unique index. Other conditions are checked programmatically. ROWID-Scan The row is fetched according to its direct address in the database M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 47

48 Join cost for two tables The optimizer tries usually to use the table with more expensive data access as the pivotal table (outer loop in nested loops) Then it searches corresponding data in the other table for each found row of the pivotal table If both tables provides only Full-Scan data access path, data in both tables are temporarily ordered and Merge-Join is used. M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 48

49 How to find out the plan? In Oracle you should have table named PLAN_TABLE available (newer versions of Oracle provide it automatically) with correct schema The optimizer then can store plan to this table, if it is asked asked to do SQL*Plus client provides option SET AUTOTRACE {OFF ON TRACEONLY} Oracle provides statement EXPLAIN PLAN M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 49

50 EXPLAIN PLAN SET STATEMENT_ID = name [INTO tab_name] FOR statement; EXPLAIN PLAN SET STATEMENT_ID = emp_dept FOR SELECT Emp.*, Dept.Loc FROM Dept, Emp WHERE Dept.DeptNo = Emp.Deptno; M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 50

51 Obtaining the execution plan (version 10+) select plan_table_output from table( dbms_xplan.display( 'PLAN_TABLE',{statement_id null}, {'ALL' 'TYPICAL' 'BASIC' 'SERIAL'} ) ); PLAN_TABLE_OUTPUT Id Operation Name Rows Bytes Cost (%CPU) SELECT STATEMENT K 270 (2) 1 NESTED LOOPS K 270 (2) 2 INDEX RANGE SCAN MF_CISPOLATR_SK_ATR_DO_PBCP (0) 3 COLLECTION ITERATOR PICKLER FETCH XMLSEQUENCEFROMXMLTYPE M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 51

52 How to find out the plan? ISQL console provides the possibility to show the plan in textual form set showplan_text on go <příkaz> go M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 52

53 Usual reccomendation: Use placeholders instead of constants in your application and bind application variables to them Two different queries have two distinct (but equal) execution plans. Their creation costs time and resources of the database SELECT * FROM Emp WHERE DeptNo=10; SELECT * FROM Emp WHERE DeptNo=20; SELECT * FROM Emp WHERE DeptNo=:d; Sometimes, of course, two CBO plans can be helpful because they are different (pokud se princip provedení odůvodněně liší). 90% of data (full s.) SELECT * FROM Soldiers WHERE Gender= M SELECT * FROM Soldiers WHERE Gender= F M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 53

54 One statement write in the same form on all places in the application Different styles cause different plans and repeated analysis of statements SELECT * FROM Emp WHERE Ename LIKE A% AND DeptNo=10; SELECT * FROM Emp WHERE DeptNo=10 AND Ename LIKE A% ; M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 54

55 If there exist more non-unique indexes on the table, RBO can choose the worse of them SELECT * FROM Person WHERE Name= John AND City= Idaho City ; Either all Johns are searched and the city is tested programmatically, or vice versa M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 55

56 Usage of one of indexes can be disabled by using some expression in the query SELECT * FROM Person WHERE CONCAT(Name, )= John AND City= Idaho City ; The ondex on Name cannot be used, the index on City will be used instead Note.: More sophisticated optimizer could recognize this trick and rewrite the query to its original form. M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 56

57 The overall cost for individual plans is computed using lot of criteria Amount of I/O operations, rows, Bytes, The cost of needed ordering operations The cost for HASH operations The plan with lowest weighted cost is chosen M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 57

58 Uses statistical information about stored data Number of different values in indexed columns, Histograms of data values in columns, Lowest/Highest values in columns Number of rows in table, Average length of one row Number of data blocks in table Number of empty data blocks in table Number of NULLs in columns For given value or interval it can be estimated The percentage of matching rows The percentage of needed blocks Their volume M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 58

59 In Oracle CBO allows create indexes over expressions, not only columns (RBO cannot use them) CREATE INDEX Emp_Income_INX ON Emp(Sal+COALESCE(Comm,0)); The query with identical expression can use the index SELECT EName FROM Emp WHERE Sal+COALESCE(Comm,0) > 25000; Query with modified expression cannot use that index SELECT EName FROM Emp WHERE COALESCE(Comm,0)+Sal > 25000; M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 59

60 Selection of optimizer ALTER SESSION SET OPTIMIZER_MODE *) = CHOOSE the optimizer is chosen according to presence of statistics ALL_ROWS CBO will be used, minimizes cost of obtaining all rows of the select indexes are less used Suitable for batch processing. FIRST_ROWS CBO will be used, minimizes cost of obtaining first few rows indexes are more used Suitable for interactive processing RULE always RBO *) Note.: Older syntax: OPTIMIZER_GOAL M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 60

61 ANALYZE TABLE tab_name {COMPUTE ESTIMATE DELETE} STATISTICS [FOR {TABLE ALL [INDEXED] COLUMNS}]; DBMS_UTILITY.ANALYZE_SCHEMA( schema_name,{ compute delete estimate } ); DBMS_STATS.GATHER_SCHEMA_STATS( sch_name ); Views in data dictionary INDEX_STATS, USER_TAB_COL_STATISTICS USER_USTATS M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 61

62 By default the option AUTO_CREATE_STATISTICS is enabled Automatical statistics generation ALTER DATABASE dbname SET AUTO_CREATE_STATISTICS {ON OFF} Manually by procedure sp_createstats Example: creation of additional statistic dodatečné for two-column valuebased on data sample CREATE STATISTICS FirstLast ON Person.Contact(FirstName,LastName) WITH SAMPLE 50 PERCENT M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 62

63 Tables Number of rows Number of rows in one block Number of empty/all blocks Sloupce Number of different values Number of NULL values Histograms of values M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 63

64 Using plus sign comments placed immediatelly after first keyword of the statement SELECT/UPDATE/INSERT/DELETE SELECT --+ list of hints Seems to be ignored SELECT /*+ list of hints */ Can be used for statement level selection of optimizer SELECT /*+ RULE */ * FROM EMP ; SELECT /*+ FIRST_ROWS */ * FROM EMP ; The hit usage (except of RULE hint) always forces to use CBO based on statistics. If statistics are not computed or are too old, the result can be contraproductive. M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 64

65 General setting for optimizer CHOOSE Optimizer choses the method according to presence / not presence of statistics RULE Optimizer uses RBO even in case of statistics are available. When using SQL-92 joins in the statement RBO hint will be ignored! ALL_ROWS Optimizer will minimize the cost for all rows retrieval FIRST_ROWS, FIRST_ROWS(n) Optimizer will minimize the cost for first / first n of rows retrieval M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 65

66 Other hints (for data access paths) FULL(tab_name) Given table should be full-scanned INDEX (tab_name index_name) Given index should be used to retrieve data from the table NO_INDEX (tab_name index_name) Given index should not be used to retrieve data from the table ORDERED The order of tables in joins should correspond to the order of appearance in FROM clause USE_NL, USE_MERGE, USE_HASH Joins should be implemented using nested loops / merge joins / hash joins M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 66

67 FULL(tab_name) SELECT /*+ FULL(Emp) */ EmpNo, Ename FROM Emp WHERE EName> X ; Use FULL SCAN even if the amount of retrieved rows is small If the table has an alias, the hint has to use this alias, it allows use the table more times with different hints M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 67

68 INDEX(jm_tabulky index [index ]) SELECT /*+ INDEX(Emp ENameInx EDeptInx) */ EmpNo, Ename FROM Emp WHERE EName LIKE SC% AND DeptNo>50; Use one of listed indexes, do not use other indexes, even if available and suitable M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 68

69 NO_INDEX(jm_tabulky index [index ]) SELECT /*+ NO_INDEX(Emp ENameInx) */ EmpNo, Ename FROM Emp WHERE EName LIKE SC% AND DeptNo>50; Do not consider listed indexes during query optimization M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 69

70 ORDERED SELECT /*+ ORDERED*/ EmpNo, Ename FROM Emp, Dept WHERE ; Tables will be joined in order of appearance in the FROM clause It saves the time by not considering other orders of tables in join M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 70

71 SELECT OPTION (hint ); Hints can be chosen from: { { HASH ORDER } GROUP { CONCAT HASH MERGE } UNION { LOOP MERGE HASH } JOIN FAST number_rows FORCE ORDER MAXDOP number_of_processors OPTIMIZE FOR { UNKNOWN = literal_constant } [,...n ] ) M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 71

72 { { HASH ORDER } GROUP Implement GROUP BY using hashing or ordering data { CONCAT HASH MERGE } UNION Implement UNION without duplicities by simple concatenating, hashing, or merging individual results { LOOP MERGE HASH } JOIN Implement joins by nested loops / merge joins / hash joins FAST number_rows Optimize query for fast retrieval of first number of rows M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 72

73 FORCE ORDER Keep order of tables in joins in according to the FROM clause MAXDOP number_of_processors Limitation of maximal degree of parallelism OPTIMIZE FOR { UNKNOWN = literal_constant } [,...n ] ) If the statement contains a variable (placeholder), suppose either given value or unknown value M. Kopecký Schema Modification and Query Optimization (NDBI026, Lect. 2) 73

Oracle DB-Tuning Essentials

Oracle DB-Tuning Essentials Infrastructure at your Service. Oracle DB-Tuning Essentials Agenda 1. The DB server and the tuning environment 2. Objective, Tuning versus Troubleshooting, Cost Based Optimizer 3. Object statistics 4.

More information

RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague

RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague course: Database Applications (NDBI026) WS2015/16 RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague Triggers Triggers Overview

More information

RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague

RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague course: Database Applications (NDBI026) WS2015/16 RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague Views Creating views Using

More information

Oracle Hints. Using Optimizer Hints

Oracle Hints. Using Optimizer Hints Politecnico di Torino Tecnologia delle Basi di Dati Oracle Hints Computer Engineering, 2009-2010, slides by Tania Cerquitelli and Daniele Apiletti Using Optimizer Hints You can use comments in a SQL statement

More information

Physical Design. Elena Baralis, Silvia Chiusano Politecnico di Torino. Phases of database design D B M G. Database Management Systems. Pag.

Physical Design. Elena Baralis, Silvia Chiusano Politecnico di Torino. Phases of database design D B M G. Database Management Systems. Pag. Physical Design D B M G 1 Phases of database design Application requirements Conceptual design Conceptual schema Logical design ER or UML Relational tables Logical schema Physical design Physical schema

More information

ENHANCING DATABASE PERFORMANCE

ENHANCING DATABASE PERFORMANCE ENHANCING DATABASE PERFORMANCE Performance Topics Monitoring Load Balancing Defragmenting Free Space Striping Tables Using Clusters Using Efficient Table Structures Using Indexing Optimizing Queries Supplying

More information

Interview Questions on DBMS and SQL [Compiled by M V Kamal, Associate Professor, CSE Dept]

Interview Questions on DBMS and SQL [Compiled by M V Kamal, Associate Professor, CSE Dept] Interview Questions on DBMS and SQL [Compiled by M V Kamal, Associate Professor, CSE Dept] 1. What is DBMS? A Database Management System (DBMS) is a program that controls creation, maintenance and use

More information

Databases IIB: DBMS-Implementation Exercise Sheet 13

Databases IIB: DBMS-Implementation Exercise Sheet 13 Prof. Dr. Stefan Brass January 27, 2017 Institut für Informatik MLU Halle-Wittenberg Databases IIB: DBMS-Implementation Exercise Sheet 13 As requested by the students, the repetition questions a) will

More information

Basant Group of Institution

Basant Group of Institution Basant Group of Institution Visual Basic 6.0 Objective Question Q.1 In the relational modes, cardinality is termed as: (A) Number of tuples. (B) Number of attributes. (C) Number of tables. (D) Number of

More information

Mahathma Gandhi University

Mahathma Gandhi University Mahathma Gandhi University BSc Computer science III Semester BCS 303 OBJECTIVE TYPE QUESTIONS Choose the correct or best alternative in the following: Q.1 In the relational modes, cardinality is termed

More information

D B M G Data Base and Data Mining Group of Politecnico di Torino

D B M G Data Base and Data Mining Group of Politecnico di Torino Database Management Data Base and Data Mining Group of tania.cerquitelli@polito.it A.A. 2014-2015 Optimizer operations Operation Evaluation of expressions and conditions Statement transformation Description

More information

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 7 Introduction to Structured Query Language (SQL)

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management Tenth Edition Chapter 7 Introduction to Structured Query Language (SQL) Objectives In this chapter, students will learn: The basic commands and

More information

DB2 SQL Class Outline

DB2 SQL Class Outline DB2 SQL Class Outline The Basics of SQL Introduction Finding Your Current Schema Setting Your Default SCHEMA SELECT * (All Columns) in a Table SELECT Specific Columns in a Table Commas in the Front or

More information

MTA Database Administrator Fundamentals Course

MTA Database Administrator Fundamentals Course MTA Database Administrator Fundamentals Course Session 1 Section A: Database Tables Tables Representing Data with Tables SQL Server Management Studio Section B: Database Relationships Flat File Databases

More information

Answer: Reduce the amount of work Oracle needs to do to return the desired result.

Answer: Reduce the amount of work Oracle needs to do to return the desired result. SQL Tuning 101 excerpt: Explain Plan A Logical Approach By mruckdaschel@affiniongroup.com Michael Ruckdaschel Affinion Group International My Qualifications Software Developer for Affinion Group International

More information

RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague

RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague seminář: Administrace Oracle (NDBI013) LS2017/18 RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague Database structure Database

More information

Oracle Syllabus Course code-r10605 SQL

Oracle Syllabus Course code-r10605 SQL Oracle Syllabus Course code-r10605 SQL Writing Basic SQL SELECT Statements Basic SELECT Statement Selecting All Columns Selecting Specific Columns Writing SQL Statements Column Heading Defaults Arithmetic

More information

Query Processing and Query Optimization. Prof Monika Shah

Query Processing and Query Optimization. Prof Monika Shah Query Processing and Query Optimization Query Processing SQL Query Is in Library Cache? System catalog (Dict / Dict cache) Scan and verify relations Parse into parse tree (relational Calculus) View definitions

More information

MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9)

MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9) Technology & Information Management Instructor: Michael Kremer, Ph.D. Class 6 Professional Program: Data Administration and Management MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9) AGENDA

More information

7. Query Processing and Optimization

7. Query Processing and Optimization 7. Query Processing and Optimization Processing a Query 103 Indexing for Performance Simple (individual) index B + -tree index Matching index scan vs nonmatching index scan Unique index one entry and one

More information

Query optimization. Elena Baralis, Silvia Chiusano Politecnico di Torino. DBMS Architecture D B M G. Database Management Systems. Pag.

Query optimization. Elena Baralis, Silvia Chiusano Politecnico di Torino. DBMS Architecture D B M G. Database Management Systems. Pag. Database Management Systems DBMS Architecture SQL INSTRUCTION OPTIMIZER MANAGEMENT OF ACCESS METHODS CONCURRENCY CONTROL BUFFER MANAGER RELIABILITY MANAGEMENT Index Files Data Files System Catalog DATABASE

More information

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe CHAPTER 19 Query Optimization Introduction Query optimization Conducted by a query optimizer in a DBMS Goal: select best available strategy for executing query Based on information available Most RDBMSs

More information

SQL. Char (30) can store ram, ramji007 or 80- b

SQL. Char (30) can store ram, ramji007 or 80- b SQL In Relational database Model all the information is stored on Tables, these tables are divided into rows and columns. A collection on related tables are called DATABASE. A named table in a database

More information

Interpreting Explain Plan Output. John Mullins

Interpreting Explain Plan Output. John Mullins Interpreting Explain Plan Output John Mullins jmullins@themisinc.com www.themisinc.com www.themisinc.com/webinars Presenter John Mullins Themis Inc. (jmullins@themisinc.com) 30+ years of Oracle experience

More information

Advanced Oracle Performance Troubleshooting. Query Transformations Randolf Geist

Advanced Oracle Performance Troubleshooting. Query Transformations Randolf Geist Advanced Oracle Performance Troubleshooting Query Transformations Randolf Geist http://oracle-randolf.blogspot.com/ http://www.sqltools-plusplus.org:7676/ info@sqltools-plusplus.org Independent Consultant

More information

Data Organization and Processing I

Data Organization and Processing I Data Organization and Processing I Data Organization in Oracle Server 11g R2 (NDBI007) RNDr. Michal Kopecký, Ph.D. http://www.ms.mff.cuni.cz/~kopecky Database structure o Database structure o Database

More information

RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague

RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague course: Database Applications (NDBI026) WS2015/16 RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague Transactions Transactional

More information

normalization are being violated o Apply the rule of Third Normal Form to resolve a violation in the model

normalization are being violated o Apply the rule of Third Normal Form to resolve a violation in the model Database Design Section1 - Introduction 1-1 Introduction to the Oracle Academy o Give examples of jobs, salaries, and opportunities that are possible by participating in the Academy. o Explain how your

More information

Chapter 12: Indexing and Hashing. Basic Concepts

Chapter 12: Indexing and Hashing. Basic Concepts Chapter 12: Indexing and Hashing! Basic Concepts! Ordered Indices! B+-Tree Index Files! B-Tree Index Files! Static Hashing! Dynamic Hashing! Comparison of Ordered Indexing and Hashing! Index Definition

More information

Oracle Database 11g: SQL Tuning Workshop

Oracle Database 11g: SQL Tuning Workshop Oracle University Contact Us: Local: 0845 777 7 711 Intl: +44 845 777 7 711 Oracle Database 11g: SQL Tuning Workshop Duration: 3 Days What you will learn This Oracle Database 11g: SQL Tuning Workshop Release

More information

.. Spring 2008 CSC 468: DBMS Implementation Alexander Dekhtyar..

.. Spring 2008 CSC 468: DBMS Implementation Alexander Dekhtyar.. .. Spring 2008 CSC 468: DBMS Implementation Alexander Dekhtyar.. Tuning Oracle Query Execution Performance The performance of SQL queries in Oracle can be modified in a number of ways: By selecting a specific

More information

Chapter 12: Indexing and Hashing

Chapter 12: Indexing and Hashing Chapter 12: Indexing and Hashing Basic Concepts Ordered Indices B+-Tree Index Files B-Tree Index Files Static Hashing Dynamic Hashing Comparison of Ordered Indexing and Hashing Index Definition in SQL

More information

Chapter 7. Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel

Chapter 7. Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel 1 In this chapter, you will learn: The basic commands

More information

Relational Model History. COSC 416 NoSQL Databases. Relational Model (Review) Relation Example. Relational Model Definitions. Relational Integrity

Relational Model History. COSC 416 NoSQL Databases. Relational Model (Review) Relation Example. Relational Model Definitions. Relational Integrity COSC 416 NoSQL Databases Relational Model (Review) Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca Relational Model History The relational model was proposed by E. F. Codd

More information

Objectives. After completing this lesson, you should be able to do the following:

Objectives. After completing this lesson, you should be able to do the following: Objectives After completing this lesson, you should be able to do the following: Write SELECT statements to access data from more than one table using equality and nonequality joins View data that generally

More information

SQL functions fit into two broad categories: Data definition language Data manipulation language

SQL functions fit into two broad categories: Data definition language Data manipulation language Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition Chapter 7 Beginning Structured Query Language (SQL) MDM NUR RAZIA BINTI MOHD SURADI 019-3932846 razia@unisel.edu.my

More information

Course Modules for MCSA: SQL Server 2016 Database Development Training & Certification Course:

Course Modules for MCSA: SQL Server 2016 Database Development Training & Certification Course: Course Modules for MCSA: SQL Server 2016 Database Development Training & Certification Course: 20762C Developing SQL 2016 Databases Module 1: An Introduction to Database Development Introduction to the

More information

INDEX. 1 Basic SQL Statements. 2 Restricting and Sorting Data. 3 Single Row Functions. 4 Displaying data from multiple tables

INDEX. 1 Basic SQL Statements. 2 Restricting and Sorting Data. 3 Single Row Functions. 4 Displaying data from multiple tables INDEX Exercise No Title 1 Basic SQL Statements 2 Restricting and Sorting Data 3 Single Row Functions 4 Displaying data from multiple tables 5 Creating and Managing Tables 6 Including Constraints 7 Manipulating

More information

Creating and Managing Tables Schedule: Timing Topic

Creating and Managing Tables Schedule: Timing Topic 9 Creating and Managing Tables Schedule: Timing Topic 30 minutes Lecture 20 minutes Practice 50 minutes Total Objectives After completing this lesson, you should be able to do the following: Describe the

More information

Databases - 4. Other relational operations and DDL. How to write RA expressions for dummies

Databases - 4. Other relational operations and DDL. How to write RA expressions for dummies Databases - 4 Other relational operations and DDL How to write RA expressions for dummies Step 1: Identify the relations required and CP them together Step 2: Add required selections to make the CP Step

More information

1 Writing Basic SQL SELECT Statements 2 Restricting and Sorting Data

1 Writing Basic SQL SELECT Statements 2 Restricting and Sorting Data 1 Writing Basic SQL SELECT Statements Objectives 1-2 Capabilities of SQL SELECT Statements 1-3 Basic SELECT Statement 1-4 Selecting All Columns 1-5 Selecting Specific Columns 1-6 Writing SQL Statements

More information

Top 5 Issues that Cannot be Resolved by DBAs (other than missed bind variables)

Top 5 Issues that Cannot be Resolved by DBAs (other than missed bind variables) Top 5 Issues that Cannot be Resolved by DBAs (other than missed bind variables) March 12, 2013 Michael Rosenblum Dulcian, Inc. www.dulcian.com 1 of 43 Who Am I? Misha Oracle ACE Co-author of 2 books PL/SQL

More information

Introduction to Query Processing and Query Optimization Techniques. Copyright 2011 Ramez Elmasri and Shamkant Navathe

Introduction to Query Processing and Query Optimization Techniques. Copyright 2011 Ramez Elmasri and Shamkant Navathe Introduction to Query Processing and Query Optimization Techniques Outline Translating SQL Queries into Relational Algebra Algorithms for External Sorting Algorithms for SELECT and JOIN Operations Algorithms

More information

Join Methods. Franck Pachot CERN

Join Methods. Franck Pachot CERN Join Methods Franck Pachot CERN Twitter: @FranckPachot E-mail: contact@pachot.net The session is a full demo. This manuscript shows only the commands used for the demo the explanations will be during the

More information

Query Processing & Optimization

Query Processing & Optimization Query Processing & Optimization 1 Roadmap of This Lecture Overview of query processing Measures of Query Cost Selection Operation Sorting Join Operation Other Operations Evaluation of Expressions Introduction

More information

B.H.GARDI COLLEGE OF MASTER OF COMPUTER APPLICATION. Ch. 1 :- Introduction Database Management System - 1

B.H.GARDI COLLEGE OF MASTER OF COMPUTER APPLICATION. Ch. 1 :- Introduction Database Management System - 1 Basic Concepts :- 1. What is Data? Data is a collection of facts from which conclusion may be drawn. In computer science, data is anything in a form suitable for use with a computer. Data is often distinguished

More information

SQL Structured Query Language Introduction

SQL Structured Query Language Introduction SQL Structured Query Language Introduction Rifat Shahriyar Dept of CSE, BUET Tables In relational database systems data are represented using tables (relations). A query issued against the database also

More information

Part III. Data Modelling. Marc H. Scholl (DBIS, Uni KN) Information Management Winter 2007/08 1

Part III. Data Modelling. Marc H. Scholl (DBIS, Uni KN) Information Management Winter 2007/08 1 Part III Data Modelling Marc H. Scholl (DBIS, Uni KN) Information Management Winter 2007/08 1 Outline of this part (I) 1 Introduction to the Relational Model and SQL Relational Tables Simple Constraints

More information

SQL Interview Questions

SQL Interview Questions SQL Interview Questions SQL stands for Structured Query Language. It is used as a programming language for querying Relational Database Management Systems. In this tutorial, we shall go through the basic

More information

Greenplum SQL Class Outline

Greenplum SQL Class Outline Greenplum SQL Class Outline The Basics of Greenplum SQL Introduction SELECT * (All Columns) in a Table Fully Qualifying a Database, Schema and Table SELECT Specific Columns in a Table Commas in the Front

More information

Understanding the Optimizer

Understanding the Optimizer Understanding the Optimizer 1 Global topics Introduction At which point does the optimizer his work Optimizer steps Index Questions? 2 Introduction Arno Brinkman BISIT engineering b.v. ABVisie firebird@abvisie.nl

More information

GIFT Department of Computing Science Data Selection and Filtering using the SELECT Statement

GIFT Department of Computing Science Data Selection and Filtering using the SELECT Statement GIFT Department of Computing Science [Spring 2013] CS-217: Database Systems Lab-2 Manual Data Selection and Filtering using the SELECT Statement V1.0 4/12/2016 Introduction to Lab-2 This lab reinforces

More information

Oracle. Exam Questions 1Z Oracle Database 11g Release 2: SQL Tuning Exam. Version:Demo

Oracle. Exam Questions 1Z Oracle Database 11g Release 2: SQL Tuning Exam. Version:Demo Oracle Exam Questions 1Z0-117 Oracle Database 11g Release 2: SQL Tuning Exam Version:Demo 1.You ran a high load SQL statement that used an index through the SQL Tuning Advisor and accepted its recommendation

More information

doc. RNDr. Tomáš Skopal, Ph.D. RNDr. Michal Kopecký, Ph.D.

doc. RNDr. Tomáš Skopal, Ph.D. RNDr. Michal Kopecký, Ph.D. course: Database Systems (NDBI025) SS2017/18 doc. RNDr. Tomáš Skopal, Ph.D. RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague

More information

Data about data is database Select correct option: True False Partially True None of the Above

Data about data is database Select correct option: True False Partially True None of the Above Within a table, each primary key value. is a minimal super key is always the first field in each table must be numeric must be unique Foreign Key is A field in a table that matches a key field in another

More information

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Database Systems: Fall 2009 Quiz I Solutions

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Database Systems: Fall 2009 Quiz I Solutions Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY 6.830 Database Systems: Fall 2009 Quiz I Solutions There are 15 questions and 12 pages in this quiz booklet.

More information

SQL Coding Guidelines

SQL Coding Guidelines SQL Coding Guidelines 1. Always specify SET NOCOUNT ON at the top of the stored procedure, this command suppresses the result set count information thereby saving some amount of time spent by SQL Server.

More information

Suppose we need to get/retrieve the data from multiple columns which exists in multiple tables...then we use joins..

Suppose we need to get/retrieve the data from multiple columns which exists in multiple tables...then we use joins.. JOINS: why we need to join?? Suppose we need to get/retrieve the data from multiple columns which exists in multiple tables...then we use joins.. what is the condition for doing joins??...yes at least

More information

Overview of Query Processing and Optimization

Overview of Query Processing and Optimization Overview of Query Processing and Optimization Source: Database System Concepts Korth and Silberschatz Lisa Ball, 2010 (spelling error corrections Dec 07, 2011) Purpose of DBMS Optimization Each relational

More information

CSE 530A. Query Planning. Washington University Fall 2013

CSE 530A. Query Planning. Washington University Fall 2013 CSE 530A Query Planning Washington University Fall 2013 Scanning When finding data in a relation, we've seen two types of scans Table scan Index scan There is a third common way Bitmap scan Bitmap Scans

More information

Databases. Relational Model, Algebra and operations. How do we model and manipulate complex data structures inside a computer system? Until

Databases. Relational Model, Algebra and operations. How do we model and manipulate complex data structures inside a computer system? Until Databases Relational Model, Algebra and operations How do we model and manipulate complex data structures inside a computer system? Until 1970.. Many different views or ways of doing this Could use tree

More information

ORACLE 12C NEW FEATURE. A Resource Guide NOV 1, 2016 TECHGOEASY.COM

ORACLE 12C NEW FEATURE. A Resource Guide NOV 1, 2016 TECHGOEASY.COM ORACLE 12C NEW FEATURE A Resource Guide NOV 1, 2016 TECHGOEASY.COM 1 Oracle 12c New Feature MULTITENANT ARCHITECTURE AND PLUGGABLE DATABASE Why Multitenant Architecture introduced with 12c? Many Oracle

More information

Mobile MOUSe MTA DATABASE ADMINISTRATOR FUNDAMENTALS ONLINE COURSE OUTLINE

Mobile MOUSe MTA DATABASE ADMINISTRATOR FUNDAMENTALS ONLINE COURSE OUTLINE Mobile MOUSe MTA DATABASE ADMINISTRATOR FUNDAMENTALS ONLINE COURSE OUTLINE COURSE TITLE MTA DATABASE ADMINISTRATOR FUNDAMENTALS COURSE DURATION 10 Hour(s) of Self-Paced Interactive Training COURSE OVERVIEW

More information

Course Outline and Objectives: Database Programming with SQL

Course Outline and Objectives: Database Programming with SQL Introduction to Computer Science and Business Course Outline and Objectives: Database Programming with SQL This is the second portion of the Database Design and Programming with SQL course. In this portion,

More information

Database Foundations. 6-3 Data Definition Language (DDL) Copyright 2015, Oracle and/or its affiliates. All rights reserved.

Database Foundations. 6-3 Data Definition Language (DDL) Copyright 2015, Oracle and/or its affiliates. All rights reserved. Database Foundations 6-3 Roadmap You are here Introduction to Oracle Application Express Structured Query Language (SQL) Data Definition Language (DDL) Data Manipulation Language (DML) Transaction Control

More information

Index. Bitmap Heap Scan, 156 Bitmap Index Scan, 156. Rahul Batra 2018 R. Batra, SQL Primer,

Index. Bitmap Heap Scan, 156 Bitmap Index Scan, 156. Rahul Batra 2018 R. Batra, SQL Primer, A Access control, 165 granting privileges to users general syntax, GRANT, 170 multiple privileges, 171 PostgreSQL, 166 169 relational databases, 165 REVOKE command, 172 173 SQLite, 166 Aggregate functions

More information

COSC 304 Introduction to Database Systems SQL DDL. Dr. Ramon Lawrence University of British Columbia Okanagan

COSC 304 Introduction to Database Systems SQL DDL. Dr. Ramon Lawrence University of British Columbia Okanagan COSC 304 Introduction to Database Systems SQL DDL Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca SQL Overview Structured Query Language or SQL is the standard query language

More information

Overview of Implementing Relational Operators and Query Evaluation

Overview of Implementing Relational Operators and Query Evaluation Overview of Implementing Relational Operators and Query Evaluation Chapter 12 Motivation: Evaluating Queries The same query can be evaluated in different ways. The evaluation strategy (plan) can make orders

More information

New Requirements. Advanced Query Processing. Top-N/Bottom-N queries Interactive queries. Skyline queries, Fast initial response time!

New Requirements. Advanced Query Processing. Top-N/Bottom-N queries Interactive queries. Skyline queries, Fast initial response time! Lecture 13 Advanced Query Processing CS5208 Advanced QP 1 New Requirements Top-N/Bottom-N queries Interactive queries Decision making queries Tolerant of errors approximate answers acceptable Control over

More information

When should an index be used?

When should an index be used? When should an index be used? Christian Antognini Trivadis AG Zürich, Switzerland Introduction One of the biggest problems tuning a SQL statement or judging if its execution plan is optimal, is to decide

More information

Chapter 12: Query Processing

Chapter 12: Query Processing Chapter 12: Query Processing Overview Catalog Information for Cost Estimation $ Measures of Query Cost Selection Operation Sorting Join Operation Other Operations Evaluation of Expressions Transformation

More information

Sql Server Syllabus. Overview

Sql Server Syllabus. Overview Sql Server Syllabus Overview This SQL Server training teaches developers all the Transact-SQL skills they need to create database objects like Tables, Views, Stored procedures & Functions and triggers

More information

Visit for more.

Visit  for more. Chapter 9: More On Database & SQL Advanced Concepts Informatics Practices Class XII (CBSE Board) Revised as per CBSE Curriculum 2015 Visit www.ip4you.blogspot.com for more. Authored By:- Rajesh Kumar Mishra,

More information

Components of a DMBS

Components of a DMBS Query Optimisation Part 1 Query Optimisation Part 1 Brendan Tierney Components of a DMBS 2 1 3 Introduction In network and hierarchical DBMSs, low-level procedural query language is generally embedded

More information

Algorithms for Query Processing and Optimization. 0. Introduction to Query Processing (1)

Algorithms for Query Processing and Optimization. 0. Introduction to Query Processing (1) Chapter 19 Algorithms for Query Processing and Optimization 0. Introduction to Query Processing (1) Query optimization: The process of choosing a suitable execution strategy for processing a query. Two

More information

Introduction to Computer Science and Business

Introduction to Computer Science and Business Introduction to Computer Science and Business This is the second portion of the Database Design and Programming with SQL course. In this portion, students implement their database design by creating a

More information

PASSWORDS TREES AND HIERARCHIES. CS121: Relational Databases Fall 2017 Lecture 24

PASSWORDS TREES AND HIERARCHIES. CS121: Relational Databases Fall 2017 Lecture 24 PASSWORDS TREES AND HIERARCHIES CS121: Relational Databases Fall 2017 Lecture 24 Account Password Management 2 Mentioned a retailer with an online website Need a database to store user account details

More information

Oracle Database: Introduction to SQL Ed 2

Oracle Database: Introduction to SQL Ed 2 Oracle University Contact Us: +40 21 3678820 Oracle Database: Introduction to SQL Ed 2 Duration: 5 Days What you will learn This Oracle Database 12c: Introduction to SQL training helps you write subqueries,

More information

Indexing. Week 14, Spring Edited by M. Naci Akkøk, , Contains slides from 8-9. April 2002 by Hector Garcia-Molina, Vera Goebel

Indexing. Week 14, Spring Edited by M. Naci Akkøk, , Contains slides from 8-9. April 2002 by Hector Garcia-Molina, Vera Goebel Indexing Week 14, Spring 2005 Edited by M. Naci Akkøk, 5.3.2004, 3.3.2005 Contains slides from 8-9. April 2002 by Hector Garcia-Molina, Vera Goebel Overview Conventional indexes B-trees Hashing schemes

More information

Objectives. After completing this lesson, you should be able to do the following:

Objectives. After completing this lesson, you should be able to do the following: Objectives After completing this lesson, you should be able to do the following: Describe the types of problems that subqueries can solve Define subqueries List the types of subqueries Write single-row

More information

Implementing Relational Operators: Selection, Projection, Join. Database Management Systems, R. Ramakrishnan and J. Gehrke 1

Implementing Relational Operators: Selection, Projection, Join. Database Management Systems, R. Ramakrishnan and J. Gehrke 1 Implementing Relational Operators: Selection, Projection, Join Database Management Systems, R. Ramakrishnan and J. Gehrke 1 Readings [RG] Sec. 14.1-14.4 Database Management Systems, R. Ramakrishnan and

More information

DRAFT SOLUTION. Query 1(a) DATABASE MANAGEMENT SYSTEMS PRACTICE 1

DRAFT SOLUTION. Query 1(a) DATABASE MANAGEMENT SYSTEMS PRACTICE 1 DATABASE MANAGEMENT SYSTEMS PRACTICE 1 DRAFT SOLUTION Remark: Solutions in Algebra reflects the choices and the values returned by the Oracle Optimizer. Query 1(a) The Oracle optimizer prefers to use the

More information

Oracle PL/SQL - 12c & 11g [Basic PL/SQL & Advanced PL/SQL]

Oracle PL/SQL - 12c & 11g [Basic PL/SQL & Advanced PL/SQL] Chapter Overview of PL/SQL Programs Control Statements Using Loops within PLSQL Oracle PL/SQL - 12c & 11g [Basic PL/SQL & Advanced PL/SQL] Table of Contents Describe a PL/SQL program construct List the

More information

Query Optimization Overview

Query Optimization Overview Query Optimization Overview parsing, syntax checking semantic checking check existence of referenced relations and attributes disambiguation of overloaded operators check user authorization query rewrites

More information

Oracle9i: SQL Tuning Workshop

Oracle9i: SQL Tuning Workshop Oracle9i: SQL Tuning Workshop Instructor Guide Vol. 2 D12395GC10 Production 1.0 January 2002 D34339 Authors Nancy Greenberg Priya Vennapusa Technical Contributors and Reviewers Howard Bradley Laszlo Czinkoczki

More information

Kathleen Durant PhD Northeastern University CS Indexes

Kathleen Durant PhD Northeastern University CS Indexes Kathleen Durant PhD Northeastern University CS 3200 Indexes Outline for the day Index definition Types of indexes B+ trees ISAM Hash index Choosing indexed fields Indexes in InnoDB 2 Indexes A typical

More information

Database Optimization

Database Optimization Database Optimization June 9 2009 A brief overview of database optimization techniques for the database developer. Database optimization techniques include RDBMS query execution strategies, cost estimation,

More information

Tuning SQL without the Tuning Pack. John Larkin JP Morgan Chase

Tuning SQL without the Tuning Pack. John Larkin JP Morgan Chase Tuning SQL without the Tuning Pack John Larkin JP Morgan Chase Who am I Originally a mainframe COBOL programmer DBA for the last 23 years, the last 15 with Oracle. UNIX (Solaris, Aix, Windows, Linux) Recently

More information

Oral Questions and Answers (DBMS LAB) Questions & Answers- DBMS

Oral Questions and Answers (DBMS LAB) Questions & Answers- DBMS Questions & Answers- DBMS https://career.guru99.com/top-50-database-interview-questions/ 1) Define Database. A prearranged collection of figures known as data is called database. 2) What is DBMS? Database

More information

1 SQL Structured Query Language

1 SQL Structured Query Language 1 SQL Structured Query Language 1.1 Tables In relational database systems (DBS) data are represented using tables (relations). A query issued against the DBS also results in a table. A table has the following

More information

Query Optimizer MySQL vs. PostgreSQL

Query Optimizer MySQL vs. PostgreSQL Percona Live, Santa Clara (USA), 24 April 2018 Christian Antognini @ChrisAntognini antognini.ch/blog BASEL BERN BRUGG DÜSSELDORF FRANKFURT A.M. FREIBURG I.BR. GENEVA HAMBURG COPENHAGEN LAUSANNE MUNICH

More information

Performance Optimization for Informatica Data Services ( Hotfix 3)

Performance Optimization for Informatica Data Services ( Hotfix 3) Performance Optimization for Informatica Data Services (9.5.0-9.6.1 Hotfix 3) 1993-2015 Informatica Corporation. No part of this document may be reproduced or transmitted in any form, by any means (electronic,

More information

Principles of Data Management

Principles of Data Management Principles of Data Management Alvin Lin August 2018 - December 2018 Structured Query Language Structured Query Language (SQL) was created at IBM in the 80s: SQL-86 (first standard) SQL-89 SQL-92 (what

More information

RESTRICTING AND SORTING DATA

RESTRICTING AND SORTING DATA RESTRICTING AND SORTING DATA http://www.tutorialspoint.com/sql_certificate/restricting_and_sorting_data.htm Copyright tutorialspoint.com The essential capabilities of SELECT statement are Selection, Projection

More information

Querying Data with Transact SQL

Querying Data with Transact SQL Course 20761A: Querying Data with Transact SQL Course details Course Outline Module 1: Introduction to Microsoft SQL Server 2016 This module introduces SQL Server, the versions of SQL Server, including

More information

Databases - 3. Null, Cartesian Product and Join. Null Null is a value that we use when. Something will never have a value

Databases - 3. Null, Cartesian Product and Join. Null Null is a value that we use when. Something will never have a value Databases - 3, Cartesian Product and Join is a value that we use when Something will never have a value Something will have a value in the future Something had a value but doesn t at the moment is a reserved

More information

Announcement. Reading Material. Overview of Query Evaluation. Overview of Query Evaluation. Overview of Query Evaluation 9/26/17

Announcement. Reading Material. Overview of Query Evaluation. Overview of Query Evaluation. Overview of Query Evaluation 9/26/17 Announcement CompSci 516 Database Systems Lecture 10 Query Evaluation and Join Algorithms Project proposal pdf due on sakai by 5 pm, tomorrow, Thursday 09/27 One per group by any member Instructor: Sudeepa

More information

The Oracle Optimizer Explain the Explain Plan O R A C L E W H I T E P A P E R A P R I L

The Oracle Optimizer Explain the Explain Plan O R A C L E W H I T E P A P E R A P R I L The Oracle Optimizer Explain the Explain Plan O R A C L E W H I T E P A P E R A P R I L 2 0 1 7 Table of Contents Introduction 1 The Execution Plan 2 Displaying the Execution Plan 3 What is Cost? 7 Understanding

More information

Query Optimizer MySQL vs. PostgreSQL

Query Optimizer MySQL vs. PostgreSQL Percona Live, Frankfurt (DE), 7 November 2018 Christian Antognini @ChrisAntognini antognini.ch/blog BASEL BERN BRUGG DÜSSELDORF FRANKFURT A.M. FREIBURG I.BR. GENEVA HAMBURG COPENHAGEN LAUSANNE MUNICH STUTTGART

More information

Databases - 3. Null, Cartesian Product and Join. Null Null is a value that we use when. Something will never have a value

Databases - 3. Null, Cartesian Product and Join. Null Null is a value that we use when. Something will never have a value Databases - 3 Null, Cartesian Product and Join Null Null is a value that we use when Something will never have a value Something will have a value in the future Something had a value but doesn t at the

More information