Presentation is loading. Please wait.

Presentation is loading. Please wait.

DB-04 Tuning OpenEdge™ SQL: Boosting Your SQL Application Performance

Similar presentations


Presentation on theme: "DB-04 Tuning OpenEdge™ SQL: Boosting Your SQL Application Performance"— Presentation transcript:

1 DB-04 Tuning OpenEdge™ SQL: Boosting Your SQL Application Performance
Steve Pittman Principle Software Engineer, SQL Team

2 Agenda OpenEdge SQL Server architecture Configuration and Security
Applications and SQL SQL Execution thru the SQL engine Tuning and best practices Questions The animated yellow box maybe used to highlight the topic you are discussing DB-04 Tuning OpenEdge SQL

3 Under Development D I S C L A I M E R
This talk includes information about potential future products and/or product enhancements. What I am going to say reflects our current thinking, but the information contained herein is preliminary and subject to change. Any future products we ultimately deliver may be materially different from what is described here. D I S C L A I M E R DB-04 Tuning OpenEdge SQL

4 OpenEdge SQL System Architecture
Servers Shared Memory SQL client SQL client SQL & 4GL Broker Note: In this picture the SQL92 server is multi-threaded (with simultaneously executing clients). Single broker can handle both 4GL and SQL requests. This drawing is not to scale! Database 4GL client 4GL client 4GL Servers DB-04 Tuning OpenEdge SQL

5 SQL Architecture SQL engine Database storage manager
Components SQL engine Statement planning Statement execution - scan, join, sort, etc. Communications Database storage manager Persistent data storage and indexes Transactions Locking Etc. Move quickly throught this slide!! DB-04 Tuning OpenEdge SQL

6 Agenda OpenEdge SQL Server architecture Configuration and Security
Applications and SQL SQL Execution thru the SQL engine Tuning and best practices The animated yellow box maybe used to highlight the topic you are discussing DB-04 Tuning OpenEdge SQL

7 OpenEdge SQL Server Configuration
Tuning the server: Threads vs. Processes Threads are better than processes Less resource consumption More sharing - pages, caches Better load balancing Faster execution Startup parameters -Mi - minimum threads (clients) per server -Ma - maximum threads (clients) per server -Mn - maximum server processes Default settings not the best for SQL! Better example: -Mi 4 -Ma 8 -Mn 4 -Mi default = 1 -Ma default = 5 -Mn default = 4 -Mi - determine number of threads started in server process P1 before next new connection is dispatched to next (possibly new) server process P2 . In general, determines “increment” of additional threads to start in server. When increment is used up, threads are started in next server process. After initial Mi allotment of threads is assigned to server process, new connections are assigned by the broker, 1 by 1, on a round-robin basis. -Ma - absolute upper bound on number of threads startable in an OE sql server process. DB-04 Tuning OpenEdge SQL

8 OpenEdge SQL - Startup Parameters
Servers Shared Memory SQL client SQL client -Mi threads min 5 connections go to sql server 1. 5 connections go to sql server 2. Subsequent connections are assigned, 1 by 1, on a round-robin basis. So, server 1 connections go 1-5, 6,7,8,9,10. -Ma threads max 4GL Servers DB-04 Tuning OpenEdge SQL

9 OpenEdge SQL Server Configuration
Separating 4GL and SQL brokers/servers … examples Example: Start a 4GL Primary broker Example: Start a Secondary SQL broker proserve Sports2000 -S H localhost -n 48 -Mn 8 -Mpb 4 -ServerType 4GL -minport maxport Mi 1 -Ma 5 -Mi - minimum number of clients (threads in OE SQL server) per server -Ma - maximum number of clients (threads in OE SQL server) per server -ServerTtype specifies that only clients of that type may connect to servers spawned by that broker and is case sensitive. -Mpb is to restrict the number of servers that can be spawned by that broker. -Mpb = number of server processes per broker = how many servers this broker can start. The secondary broker uses 1 one of the -Mn (Specify the maximum number of remote client servers that a broker can start) to ID itself. Some groups of parameters define ‘database access and shared resources’ - DB server performance parameters - DB server internationalization parameters - DB server statistics parameters They are common to all brokers and servers running on a single physical database They are set by the first broker started on the database One group of parameters defines ‘database broker resources’ - The sever network parameters They define the 'client access resources' shared by all servers spawned from the broker In this group you can also find some specific parameters linked to the Admin. Service and java class path for SQL-92 The DB server type parameters allow to start either: An Auto Server (-m1 – This is used internally by PROGRESS) A single DB server (-m2) A secondary login broker (-m3) Helps to separate administration task for SQL-92 and 4GL. NOTE: for a list of the parameters that are in each group, please check the manual called "progress startup command and parameter reference" section 3.4 progress database server parameters proserve Sports2000 -S H localhost -m3 –Mpb 3 -ServerType SQL -minport maxport Mi 4 -Ma 8 DB-04 Tuning OpenEdge SQL

10 OpenEdge SQL - Configured
SQL Broker SQL Servers Shared Memory SQL client SQL client Note: In this picture the SQL92 server is multi-threaded (with simultaneously executing clients). Database 4GL client 4GL client 4GL Servers 4GL Broker DB-04 Tuning OpenEdge SQL

11 OpenEdge SQL Security Model
Making your data safe and accessible Authentication Who am I? Database SQL Server SQL client User List aaa jones smith DB-04 Tuning OpenEdge SQL

12 OpenEdge SQL Security Model
Enabling safe data access Authorization What can I do? Closed model (SQL) vs. open model (4GL) Every action possible must be authorized Privileges DBA - can do everything Table (also column) privileges Sequence, stored procedure privileges Common error “Access Denied (Authorization failed) (7512)” DBA privilege - use discretion in granting this powerful privilege DB-04 Tuning OpenEdge SQL

13 OpenEdge SQL Security Model
Best practices Require user authentication Define two, limited-use DBA users Do not use predefined system DBA userid, please!! Grant table privileges to all or selected users GRANT is online DBA privilege - use discretion in granting this powerful privilege DB-04 Tuning OpenEdge SQL

14 Agenda OpenEdge SQL Server architecture Configuration and Security
Applications and SQL SQL Execution thru the SQL engine Tuning and best practices The animated yellow box maybe used to highlight the topic you are discussing DB-04 Tuning OpenEdge SQL

15 Applications and OpenEdge SQL
A look at the relationship Representative applications Crystal Reports Java, WebSphere, and JDBC Delphi, ODBC, Web server Database SQL Server SQL client Client and server interaction DB-04 Tuning OpenEdge SQL

16 Statement-oriented Select SQL statements Prepare, execute, fetch cycle
Result set ODBC: fetch array size Statement may not be visible (Crystal, etc.) Select onum, name, cnum … from pub.customer c, pub.orders o where c.custnum = o.custnum SQL Server Database SQL client 8765 General Motors Toyota Mfg, Inc Chrysler Motors 274 … … … DB-04 Tuning OpenEdge SQL

17 Statement-oriented Update sql statements Prepare, execute “cycle”
Simple execute message exchange No table data flow between client and server Update pub.orders set delivery_date = ‘ ’ where delivery_date = ‘ ’ SQL Server Database SQL client 2 rows updated DB-04 Tuning OpenEdge SQL

18 Statement-oriented Patterns of statements
Similar statement are executed by common prepared statement Select * from sales where date =‘06/15/05’; Select * from sales where date =‘01/08/04’; Automatic optimization for statements on a connection Select * from pub.sales where date = ‘06/15/05’ Select * from pub.sales where date = ‘01/08/04’ SQL Server Column alias in select list disables statement re-use. Database SQL client 8765 General Motors Toyota Mfg, Inc Chrysler Motors 274 … … … 3205 Laval Motors 689 DB-04 Tuning OpenEdge SQL

19 Transactions Isolation levels Read Committed - default Repeatable Read
Change via ODBC/JDBC API ODBC DSN Advanced option SQL Server SQL client 1 Database 4GL client 2 DB-04 Tuning OpenEdge SQL

20 Schemas Sets of tables with common owner PUB schema Default schema
Schema for inter-operability with 4GL Default schema Changing the default Set schema ‘pub’ ; SQL Server Cannot login as PUB or SYSPROGRESS if _user is empty. Can create PUB or SYSPROGRESS in _User, but PLEASE do not do this !!! Can create public synonym to avoid using schema name in table references. PUB SMITH SQL client JONES DB-04 Tuning OpenEdge SQL

21 Agenda OpenEdge SQL Server architecture Configuration and Security
Applications and SQL SQL Execution thru the SQL engine Tuning and best practices The animated yellow box maybe used to highlight the topic you are discussing DB-04 Tuning OpenEdge SQL

22 Executing SQL Statements
What the server does Build query plan for SQL statement Execute query plan to build result set Stream result set back to client How to choose best query plan? OpenEdge SQL Server Query Plan Select * from T1,T2 where T1.f=T2.g Column alias in select list disables statement re-use. Join Table Scan T1 Index Scan T2 Database DB-04 Tuning OpenEdge SQL

23 What’s in a Query Plan Query plan elements Organization and form
Building blocks for execution Query plan elements Table scan Index scan Join Restrict Project Sort Organization and form What’s useful to know Define these terms while talking about them. User does not need to know internal form and content of query plan to get better application performance. Just need to know that query plan is built, and what influences the way the plan is built. DB-04 Tuning OpenEdge SQL

24 Building the Query Plan
sql statement schema sql statistics SQL Optimizer U s e r Analogy - compiler optimization. SQL Runtime Query plan DB-04 Tuning OpenEdge SQL

25 Cost-based Optimization
What does this mean? Optimization model Figure out all feasible ways to do a step Figure out the costs of each way Choose way with smallest cost Optimize from the inside out Optimize table access Optimize joins Optimize result set What cost is DB-04 Tuning OpenEdge SQL

26 How the Optimizer Knows Cost
Rule-based mode When no statistics exist Table and index metadata number of key components used unique and non-unique indexes Default column selectivity per operator “=” is .04, “between” is .1, etc. Heuristics Assume all tables have n K rows Cost = cardinality * selectivity * row-cost * k Define all terms - statistics, cardinality. By default, no statistics exist. Rules assume even data distribution across tables (~same #rows) and within tables (no skew). DB-04 Tuning OpenEdge SQL

27 How Optimizer Knows Cost
Statistics-based mode - basic statistics Table statistics - cardinality Column statistics - data distribution++ Individual column selectivity per operator % of table’s data returned by predicate Combining multiple columns selectivities Best for range operators(“between”, etc.), especially in Version 9 Cost = cardinality * selectivity * row-cost * k Illustration follows on next page. By default, no statistics exist. BAsic statistics = table statistics + column statistics. DB-04 Tuning OpenEdge SQL

28 How Optimizer Knows Cost
Default statistics select * from pub.customer c, pub.order o where c.custnum = o.custnum and o.orderdata between ‘05/01/05’ and ‘05/30/05’ What percentage of data - column statistics Illustration follows on next page. Default statistics = table statistics + column statistics. How many rows - table statistics DB-04 Tuning OpenEdge SQL

29 More on Column Statistics
Based on sampling table’s data “Histogram” derived from sampled data OpenEdge 10 vs. Version 9 New: estimated number of distinct values per histogram bucket - an explanation… New: extensibility in statistics format in schema 110 230 340 424 545 676 757 868 990 1104 Define histogram. Example - Histogram of 2000 random integers 95 101 92 81 108 94 102 100 96 104 Example - number distinct values for Histogram DB-04 Tuning OpenEdge SQL

30 How the Optimizer Knows Cost
Statistics-based mode - index statistics Counts number of values for components of index Prefixes of an index key - leading sequence of key components Gives most precise estimate of number of rows satisfying “=” and “in” operators Accounts for correlation between components of an index key Can accurately model very, very low selectivity and very high selectivity DB-04 Tuning OpenEdge SQL

31 How Optimizer Knows Cost
Index statistics select * from pub.customer c, pub.order o where c.custnum = o.custnum and o.orderdata between ‘05/01/05’ and ‘05/30/05’ Illustration follows on next page. Default statistics = table statistics + column statistics. How many matching rows - index statistics DB-04 Tuning OpenEdge SQL

32 More on Index Statistics
Count of number of unique values for each prefix OpenEdge 10 vs. Version 9 OE 10: counts for all prefixes Prefix - key components 1 to n V9: counts for first key component, and last 3 prefixes V9 “interpolation” for prefixes without counts Estimate via “straight line” between first 2 counts Examples follows on next page. DB-04 Tuning OpenEdge SQL

33 Example - OpenEdge 10 Index Statistics
Sample single table query select … from Sales_History where terr_id = ‘abc’ and subt_id = 1 and yr = 2004 and zip = ‘05601’ and demo_cat = ‘xyz’ and cust_stat = ‘M’ and regn = ‘NE’ and countycd = 5 ; Explain that counts are #distinct values, which gives computation for #matching rows. Concept of prefixes and what they really mean needs clear illustration and use of these examples. DB-04 Tuning OpenEdge SQL

34 Example - OpenEdge 10 Index Statistics
2004 abc Indexes and key components: 10K 50K 90 100K Xsales_terr 1 056 abc M xyz index statistics 90 10K 20K 300K 800K 1M Xconsumer_id Explain that counts are #distinct values, which gives computation for #matching rows. Concept of prefixes and what they really mean needs clear illustration and use of these examples. 5 NE Assume cardinality (total number of rows) = 1,000,000 75 5 Xmarket_seg DB-04 Tuning OpenEdge SQL

35 Example - Cost via Index Statistics
#comps count Xconsumer_id 1 90 2 10K 3 20K 4 300K 5 800K 6 1M index statistics Cost = (1M/ 800K )rows * IO cost per row select … from Sales_History where terr_id = ‘abc’ and subt_id = 1 and zip = ‘05601’ and demo_cat = ‘xyz’ and cust_stat = ‘M’; 5 components specified DB-04 Tuning OpenEdge SQL

36 Optimizing Join Execution
Or, What gets optimized Join order Join methods index join (= augmented nested loop) nested loop dynamic index (looks like index join) Hash join when low data volume Index join when larger data volume DB-04 Tuning OpenEdge SQL

37 What Optimizer Does for Join Order
Consider many possible join orders choose least cost order Use join cardinality as cost metric Joining small amount of data to larger amount of data is usually least cost Cost estimation drivers Table statistics Index statistics OpenEdge 10 and V9.1E employ much more powerful join order exploration Cardinality drives join order, and table statistics drive much of cardinality estimation. Mention OE 10.0B (and 9.1E) join order improvements - better costing, more join orders - yielding much improved results for joins over many tables. Improvement is especially pronounced when the tables being joined include a few very large tables and several, to many, very small tables. DB-04 Tuning OpenEdge SQL

38 Planning Join Method - Index Join
Or, augmented nested loop Joined data Select … From Sales s, SalesHist h Where s.city = ‘MyTown’ And s.acct = h.acct ; Join get 1 row Sales SalesHist scan bracket rows index k-OrdL Mention, other methods - nested loops, dynamic index, merge DB-04 Tuning OpenEdge SQL

39 Example - OpenEdge10 Index Statistics
F2 F3 F1 Indexes and key components: 10K 350K 90 700K index statistics Xsales_terr F2 F4 F1 F6 F5 select … from Sales s, Sales_History h where s.terr = h.F1 and s.acct = h.F2 and s.city = h.F3 and s.col01 = h.F4 and s.col02 = h.F5 and s.regn = h.F10 and s.segid = h.F11 90 100K 800K 1M 10k 20k Xconsumer_id F11 F10 75 5 Xmarket_seg DB-04 Tuning OpenEdge SQL

40 Agenda OpenEdge SQL Server architecture Configuration and Security
Applications and SQL SQL Execution thru the SQL engine Tuning and best practices The animated yellow box maybe used to highlight the topic you are discussing DB-04 Tuning OpenEdge SQL

41 What to Tune Tune your SQL server SQL Statistics Releases
Tune your SQL statements Possible problems Finding problems Special situations OpenEdge SQL Server SQL client Database Tune here DB-04 Tuning OpenEdge SQL

42 Tuning Your SQL Server Create, or update, sql statistics
Move to newer release OpenEdge 10.0B is better than 10.0A OpenEdge 10.0A is better than Version 9.1E Version 9.1E is better than 9.1D Latest Service Pack OpenEdge 10 service packs Version 9.1 service packs Possibly consider adding indexes DB-04 Tuning OpenEdge SQL

43 Updating SQL Statistics
Default statistics “update statistics [for <table name>];” Best statistics “update table statistics and index statistics and column statistics [for <table name>];” reads all of each index for all tables, or for one table. May be resource intensive Example - 4.5G customer db, 600 tables 4500 indexes Index stats runtime = 25 cpu minutes Index statistics drive best join optimizations Must be DBA When to do relationships between tables or indexes change Update Statistics run on Solaris server: When to do additional alterntives: once (if no stats exist) SUNW,Sun-Fire-880 cpu0 is a "1050 MHz SUNW,UltraSPARC-III+" CPU cpu1 is a "1050 MHz SUNW,UltraSPARC-III+" CPU cpu2 is a "1050 MHz SUNW,UltraSPARC-III+" CPU cpu3 is a "1050 MHz SUNW,UltraSPARC-III+" CPU See more details in Appendix on runnings specific types of statistics. DB-04 Tuning OpenEdge SQL

44 Tuning Your SQL Statements
Possible problems and remedies Join relationships not completely expressed in predicates Remedy - more, better join predicates on sql statements Every pair of tables with a relationship should have a predicate giving that relation “select … from pub.orders O, pub.orderlines L where O.onum = L.onum” This example is overly simplistic but it makes the point!! DB-04 Tuning OpenEdge SQL

45 Tuning Your SQL Statements
Possible problems and remedies - more Leading keys of indexes not specified Remedy - give predicates on leading keys Predicates best for index use not used Remedy - best are “=”, IN Almost best - BETWEEN Good - >, >=, <, <= Note - OR can disable optimizations Several similar indexes not distinguished as expected Remedy: index statistics To see index and index key component definitions, use some of the available sql tools such as: DB Visualizer WinSQL Etc. DB-04 Tuning OpenEdge SQL

46 Tuning Your SQL Statements
Possible problems and remedies - example F1 F1 F2 F3 F4 Indexes and key components: Xsales_terr select … from Sales s, Sales_History h where s.accno = h.F2 and s.city = h.F3 and s.col01 = h.F4 and s.col02 = h.F5 and s.regn = h.F10 and s.segid = h.F11 F1 F1 F2 F4 F5 F6 F7 s.terr = h.F1 Xconsumer_id and Question for audience: So, which index looks least costly for a join to the Sales History table?? F11 F10 Xmarket_seg DB-04 Tuning OpenEdge SQL

47 Tuning Your SQL Statements
Finding problems Time: do simple timing of data access requests Inspect: SQL statement executed Investigate: SQL virtual system table for query plan Access query plan for sql statement executed Query plan data will show: tables indexes joins predicates order Note: only your query plans available (currently) Must be DBA or have DBA grant privileges Similar in concept to 4GL xref. DB-04 Tuning OpenEdge SQL

48 Getting the Query Plan Basic form Simplify with views
select substring("_Description",1,80) from pub."_Sql_Qplan“ where "_Pnumber" = (select max("_Pnumber") from pub."_Sql_Qplan" where "_Ptype" > 0 ); Simplify with views See Appendix for how to define view. select * from my_Qplan; DB-04 Tuning OpenEdge SQL

49 Getting the Query Plan Get your SQL statement
Crystal Reports: Database menu “Show SQL query …” Copy into a SQL query tool SQL Explorer, WinSQL, DB Visualizer Run your statement Run the SQL statement to get query plan See Appendix for how to define view. DB-04 Tuning OpenEdge SQL

50 Query Plan - Operations
What you need to find Order of operations Top to bottom Tables Indexes Index keys Joins Join predicates DB-04 Tuning OpenEdge SQL

51 Query Plan - Operations
What you can skip Things to ignore Project, sort Sometimes useful to check out Restrict Dynamic index DB-04 Tuning OpenEdge SQL

52 Query Plan - What to Look for
Single-table query Example from simple single table select “select … from pub.customer where custnum between 1000 and 1100” Simple indentation to show tree form SELECT COMMAND. PROJECT [66] ( | PROJECT [64] ( | | PUB.CUSTOMER. [0]( | | | INDEX SCAN OF ( | | | | CustNum, | | | | | (PUB.CUSTOMER.CustNum) between (1000,1100)) DB-04 Tuning OpenEdge SQL

53 Query Plan - What to Look for
Two-table query Example with 1 join key -- 1 key join select c.custnum, c.name, o.ordernum, o.orderdate from pub.customer c, pub.order o where custnum between 1000 and 1021 and c.custnum = o.custnum; Show queries for these 2 joins (here, next page) and coordinate different slides via colors. DB-04 Tuning OpenEdge SQL

54 Query Plan - What to Look for
Example with 1 join key | JOIN [13][AUG_NESTED_LOOP-JOIN] | | | PUB.O. [12]( | | | | INDEX SCAN OF ( | | | | | CustOrder, | | | | | | (PUB.O.CustNum) between (…) | | (PEXPR3) = (PEXPR5) | | -- above defines ANL left side keys <relop> right side keys. | | | PUB.C. [11]( | | | | | CustNum, | | | | | | (PUB.C.CustNum) = (null)) Explain notions of left side and right side in join, and refer to real data. DB-04 Tuning OpenEdge SQL

55 Query Plan - What to Look for
Two-table query Example with 2 join keys -- 2 key join select o.ordernum, o.orderdate, l.itemnum from pub.order o, pub.orderline l where o.custnum between 1 and 3 and o.ordernum = l.ordernum and o.custnum = l.linenum; Show queries for these 2 joins (here, next page) and coordinate different slides via colors. DB-04 Tuning OpenEdge SQL

56 Query Plan - What to Look for
Example with 2 join keys JOIN [13][AUG_NESTED_LOOP-JOIN] | | PUB.O. [2]( | | | INDEX SCAN OF ( | | | | CustOrder, | | | | | (PUB.O.CustNum) between (1,3)) | (PEXPR1, PEXPR3) = (PEXPR5, PEXPR6) | -- above defines ANL left side keys <relop> right side keys. | | | PUB.L. [3]( | | | | INDEX SCAN OF ( | | | | | orderline, | | | | | |(PUB.L.Ordernum, PUB.L.Linenum) = (null,null)) Explain notions of left side and right side in join, and refer to real data. DB-04 Tuning OpenEdge SQL

57 Tuning Your SQL Statements
Special situations Experiment with alternate queries without cost of query execution! Use NOEXECUTE to experiment Test, inspect query plan, repeat until done OpenEdge 10 and Progress Version 9 NOEXECUTE is 1 word Example: select … from Table1 t1, Table2 t2 where t1.key = 5 and t1.key = t2.key NOEXECUTE; DB-04 Tuning OpenEdge SQL

58 Tuning Your SQL Statements
Special situations Forcing the join order NO REORDER phrase at end of FROM clause When all else fails! Example: Index hints Use carefully - not deterministic select … from Table1, Table2, Table3 {NO REORDER} where … ; DB-04 Tuning OpenEdge SQL

59 Index Hint Syntax Choose index if it is an eligible candidate
WITH ( INDEX ( <index name> ) ) Choose index if it is an eligible candidate select … from PUB.ih_hist ih_hist, PUB.pt_mstr pt_mstr with (index(pt_part_type)), PUB.idh_hist idh_hist where idh_hist.idh_part = pt_mstr.pt_part and ih_hist.ih_inv_nbr = idh_hist.idh_inv_nbr and pt_mstr.pt_part_type = ‘FG’ and ih_hist.ih_inv_date <= ’01/24/2005’ and ih_hist.ih_inv_date >= to_date(‘01/24/2005’) From actual customer example. DB-04 Tuning OpenEdge SQL

60 In Summary OpenEdge SQL Server configuration
What the server does for your application Tuning to make the server do what you want a. Cookbook tuning practices b. Things to observe - analogy - how fast your car is going… - analogy - what your tire inflation pressure is … DB-04 Tuning OpenEdge SQL

61 Related SQL Exchange Sessions
DB-15: Developing Performance-Oriented ODBC/JDBC OpenEdge Applications Wednesday, 8 June, 2:15pm - 3:15pm DB-07: OpenEdge SQL and Sonic - Using JMS with SQL Applications Tuesday, 7 June, 9:15am - 10:15am DB-09: Database Roadmap Tuesday, 7 June, 2:15pm - 3:15pm DB-04 Tuning OpenEdge SQL

62 Questions? DB-04 Tuning OpenEdge SQL

63 Thank you for your time! DB-04 Tuning OpenEdge SQL

64 DB-04 Tuning OpenEdge SQL

65 Appendix - online resources
White paper on query optimizer Collection of white papers Getting Started with Crystal ODBC, JDBC Configuration Locking Index statistics Server configuration Visit: DB-04 Tuning OpenEdge SQL

66 Appendix - online resources
Documentation Knowledge base articles 19968, p secondary broker authorization 21676, 20007, query plan DB-04 Tuning OpenEdge SQL

67 OpenEdge SQL Server Configuration
Separating 4GL and SQL brokers/servers … syntax 4GL Primary Broker -n and -Mn Primary Broker Specific SQL Secondary Broker proserve dbname -S n -H x -n n -Mn n -Mpb n -ServerType 4GL -minport n -maxport n -Mi n -Ma n Analyzing user needs 1. Determine if your database would support both SQL and 4GL users. 2. For each server type (SQL and 4GL), determine: ·         the maximum number of servers, ·         the maximum number of servers per broker, and ·         the maximum number of remote clients per server, 3. To calculate the maximum number of users in the database, use this formula: -n = Maximum SQL users + Maximum 4GL users + One per each additional broker + All other processes (APWs, BIWs, AIWs, PROMONs, online backups) 4. To calculate the maximum number of servers and brokers in the database, use this formula: -Mn = (Sum of all –Mpb values) + One per each additional broker Motivation 1. Apply configuration parameters -Ma, -Mi, -Mn to their respective server type, since these values affect sql and 4GL server in differing ways. 2. Limit total resources going to sql, thus reserving resources for transaction workload (presumably on 4GL server). Starting up SQL and 4GL brokers 1. For the SQL secondary broker, invoke PROSERVE with the following: ·         Use –m3 to define this sql broker as a secondary broker. ·         Use the –n and –Mn results from the formula above. ·         Set –Ma to the maximum number of SQL users (threads). ·         Set –Mpb to the maximum number of servers (server processes) for this SQL broker. ·         Set –ServerType to SQL. 2. For the 4GL broker, invoke PROSERVE with the following:          Set –Ma to the maximum number of 4GL users. ·         Set –Mpb to the maximum number of servers for this 4GL broker. ·         Set –ServerType to 4GL. -H host-name Specifies the host on which the database resides. -S service-name ·         Specifies the service name or port number to be used by a broker. Valid port range is from 2000 to ·         Is required only for remote clients and SQL clients. -N network-type Specifies the network communications protocol: TCP. -n n Specifies the maximum number of users for a database. Default: 21. Note: Users include remote clients and processes such as APWs, BIWs, AIWs, PROWDOG, PROMONs, and online backups. -Mn n Specifies the maximum number of servers and brokers. It is only required for the primary broker. -Ma n Specifies the maximum number of remote clients per server. Default: 5. Recommended: 10. -Mi n Specifies the minimum number of remote clients (SQL threads) per server. Default: 1. -Mpb n Specifies the maximum number of servers per broker. Default: 4. -m3 Starts an additional broker. -ServerType type Specifies the server type. Valid values are 4GL, SQL, and Both. Specifies that only clients of that type may connect to servers spawned by that broker and is case sensitive. There is a slight performance gain by segregating the port ranges. There is a savings of 6 network type system calls. The secondary broker uses 1 one of the -Mn (Specify the maximum number of remote client servers that a broker can start) to ID itself. One group of parameters defines ‘database broker resources’ - The server network parameters They define the 'client access resources' shared by all servers spawned from the broker In this group you can also find some specific parameters linked to the Admin. Service and java class path for SQL-92 The DB server type parameters allow to start either: A secondary login broker (-m3) Helps to separate administration task for SQL-92 and 4GL. NOTE: for a list of the parameters that are in each group, please check the manual called "progress startup command and parameter reference" section 3.4 progress database server parameters proserve dbname -S n -H x -m3 –Mpb n -ServerType SQL -minport n -maxport n -Mi n -Ma n DB-04 Tuning OpenEdge SQL

68 Appendix - setting default schema for ODBC
In Windows registry, find entry for HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI Find sub-entry for your ODBC Data Source Name …\SOFTWARE\ODBC\ODBC.INI\<DSN NAME> Create new string value for schema name: Value name: …\ODBC\ODBC.INI\<DSN NAME>\DefaultSchema Value data: <your schema name> Example: [HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\PD6D1KPM001] "Driver"="c:\\progress-91d\\bin\\PGPRO915.DLL" "Description"="" "HostName"="cuttyhunk" "PortNumber"="2525" "DatabaseName"="test1" "LogonID"="pdadmin" "StaticCursorLongColBuffLen"="4096" "DefaultIsolationLevel"="SQL_TXN_REPEATABLE_READ" "ArraySize"="50" "DefaultLongDataBuffLen"="2048" "DefaultSchema"="PUB" DB-04 Tuning OpenEdge SQL

69 OpenEdge SQL Security Model
Commands GRANT statement GRANT is online Example “grant select on pub.orders to jones;” “grant all on pub.orders to public;” REVOKE statement REVOKE is offline “revoke all on pub.orders from public;” Who can grant: DBA, creator, grantee. Who can revoke table privs: grantor only (DBA cannot revoke if granted by someone else). Who can revoke DBA privs: DBA (any DBA). For details, see our online sql docs (or any sql reference). DB-04 Tuning OpenEdge SQL

70 Security Considerations
Privileges – Syntax: GRANTing them (2 types) Database wide (system admin or general creation) For specified Tables or Views Where ‘privilege’ is: { SELECT | INSERT | DELETE | INDEX | UPDATE [ ( column , column , ... ) ] | REFERENCES [ ( column , column , ... ) ] } GRANT { DBA, RESOURCE } TO user_name [, user_name ] , …; GRANT { privilege [, privilege ], … | ALL } ON table_name TO { user_name [, user_name ] , … | PUBLIC } [ WITH GRANT OPTION ]; RESOURCE Allows the specified users to issue CREATE statements. DBA Allows the specified users to create, access, modify, or delete any database object, and to grant other users any privileges. TO username [ , username ] , ... Grants the specified privileges on the table or view to the specified list of users. SELECT Allows the specified users to read data from the table or view. INSERT Allows the specified users to add new rows to the table or view. DELETE Allows the specified users to delete rows from the table or view. INDEX Allows the specified users to create an index on the table or view. UPDATE [ ( column , column , ... ) ] Allows the specified users to modify existing rows in the table or view. If followed by a column list, the users can modify values only in the columns named. REFERENCES [ ( column , column , ... ) ] Allows the specified users to refer to the table from other tables’ constraint definitions. If followed by a column list, constraint definitions can refer only to the columns named. CREATE USER ‘name’,’pass’ DB-04 Tuning OpenEdge SQL

71 Security Considerations
Privileges – Syntax: REVOKEing them (2 types) Database wide (system admin or general creation) For specified Tables or Views Where ‘privilege’ is: { SELECT | INSERT | DELETE | INDEX | UPDATE [ ( column , column , ... ) ] | REFERENCES [ ( column , column , ... ) ] } REVOKE { DBA, RESOURCE } FROM user_name [, user_name ] , …; REVOKE [ GRANT OPTION FOR ] { privilege [, privilege ], … | ALL [ PRIVILEGES ] } ON table_name FROM { user_name [, user_name ] , … | PUBLIC } [ RESTRICT | CASCADE ]; GRANT OPTION FOR Revokes the GRANT option for the privilege from the specified users. The actual privilege itself is not revoked. If specified with RESTRICT, and the privilege is passed on to other users, the REVOKE statement fails and generates an error. Otherwise, GRANT OPTION FOR implicitly revokes any privilege the user might have given to other users. RESTRICT | CASCADE Prompts SQL to check to see if the privilege being revoked was passed on to other users. This is possible only if the original privilege included the WITH GRANT OPTION clause. If so, the REVOKE statement fails and generates an error. If the privilege was not passed on, the REVOKE statement succeeds. If the REVOKE statement specifies CASCADE, revoking the access privileges from a user also revokes the privileges from all users who received the privilege from that user. DB-04 Tuning OpenEdge SQL

72 Join method - nested loop
Select … From Order O, OrderLine L Where O.ordnum = 1004 And O.ordnum = L.ordnum; Joined data Join and eval get 1 row Order OrderLine scan all rows Suppose both tables have indexes on order number. Each table can be accessed with a constant key value. DB-04 Tuning OpenEdge SQL

73 Join method - dynamic index
Or, index join Joined data Select … From Order O, OrderLine L Where O.city = ‘MyTown’ And O.shipper = L.shipper; Join get 1 row Order scan bracket rows dynamicindex Temp table with extracted, indexed OrderLine data DB-04 Tuning OpenEdge SQL

74 Updating sql statistics
Specific categories of statistics Table statistics “update table statistics [for <table name>];” Column statistics “update [all] column statistics [for <table name>];” Index statistics “update index statistics [for <table name>];” reads all of each index for 1, or all, tables. If an index is added, and index statistics exist, do “update index statistics for <table name>”. DB-04 Tuning OpenEdge SQL

75 Appendix - query plan view 1
-- to show all of query plan for most recent statement. create view qplan_full as select * from pub."_Sql_Qplan" where "_Pnumber" = (select max( "_Pnumber" ) from pub."_Sql_Qplan" where "_Ptype" > 0 ); grant select on qplan_full to public; create public synonym qplan_full for qplan_full ; commit work; DB-04 Tuning OpenEdge SQL

76 Appendix - query plan view 2
-- try to show just the highlights of query plan, omitting data specifics. create view qplan_no_data as select * from pub."_Sql_Qplan" where "_Pnumber" = (select max( "_Pnumber" ) where "_Ptype" > 0 ) and "_Description" not like '% , %' and "_Description" not like '%, PEXPR%' and "_Description" not like '%, substr%' and "_Description" not like '%| )' and "_Description" not like '%| )%' and "_Description" not like '%| ,%' and "_Description" not like '%callback%' and "_Description" not like '%col id# %' and "_Description" not like and "_Description" not like '%terminate%' and ("_Description" not like '% )' or "_Description" like '%OJ Predicate%' ) ; grant select on qplan_no_data to public; create public synonym qplan_no_data for qplan_no_data ; commit work; DB-04 Tuning OpenEdge SQL

77 Appendix - query plan “definition”
Table "_Sql_Qplan" exists as if it had been created by the sql syntax below The definition of this sql virtual system table is not visible to client tools such as Crystal Reports. create table "_Sql_Qplan" ( "_Pnumber" integer not null, plan number. "_Ptype" integer not null, plan type. "_Dtype" integer not null, description type. "_Description" varchar(255) not null, -- description line. "_Dseq" integer not null description sequence#. ); DB-04 Tuning OpenEdge SQL


Download ppt "DB-04 Tuning OpenEdge™ SQL: Boosting Your SQL Application Performance"

Similar presentations


Ads by Google