71
DB-16: In Any Case, the Devil’s in the DataServer Details David Moloney Principal, Progress OpenEdge That which we persist in doing becomes easier, not that the task itself has become easier, but that our ability to perform it has improved. Ralph Waldo Emerson (1803 - 1882)

DB-16: In Any Case, the Devil’s in the DataServer Details

  • Upload
    kevyn

  • View
    58

  • Download
    8

Embed Size (px)

DESCRIPTION

DB-16: In Any Case, the Devil’s in the DataServer Details. That which we persist in doing becomes easier, not that the task itself has become easier, but that our ability to perform it has improved. Ralph Waldo Emerson (1803 - 1882). David Moloney. Principal, Progress OpenEdge. - PowerPoint PPT Presentation

Citation preview

Page 1: DB-16: In Any Case, the Devil’s in the DataServer Details

DB-16: In Any Case, the Devil’s in the DataServer Details

David MoloneyPrincipal,

Progress OpenEdge

That which we persist in doing becomes easier, not that the task itself has become easier, but that our ability to perform it has improved.

Ralph Waldo Emerson (1803 - 1882)

Page 2: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation2 DB-16: In Any Case, the Devil’s in the DataServer Details

Agenda

A Story Terminology & Technology Sync-up The Devils in the Details

• Case Studies–ABL & DataServer–ABL & the RDBMS–DataServer & RDBMS–DataServer & API Access Drivers

DataServer Performance Summary & Questions

Page 3: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation3 DB-16: In Any Case, the Devil’s in the DataServer Details

A Story

Mary and the three DataServers

Once Upon A Time …

Page 4: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation4 DB-16: In Any Case, the Devil’s in the DataServer Details

Mary meets Compiler

For Each

Display Cust

ABL

Page 5: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation5 DB-16: In Any Case, the Devil’s in the DataServer Details

Client meets Server

OpenEdge™

DatabaseOpenEdge™

Database

Page 6: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation6 DB-16: In Any Case, the Devil’s in the DataServer Details

Where’s the love ? Where’s my pie ?

OracleOracleMicrosoft

SQL Server

Microsoft

SQL Server

IBM

DB2

IBM

DB2

Page 7: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation7 DB-16: In Any Case, the Devil’s in the DataServer Details

For Each What ?

For Each

Display Cust

ABL

Habla“For Each” ?

Page 8: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation8 DB-16: In Any Case, the Devil’s in the DataServer Details

Hmmm….

For Each

Display Cust

ABL

Page 9: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation9 DB-16: In Any Case, the Devil’s in the DataServer Details

I’ve got Bingo !

For Each

Display Cust

ABL

Page 10: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation10 DB-16: In Any Case, the Devil’s in the DataServer Details

OE DB OE DB

Trusted friends

For Each

Display Cust

ABL

ODBCDriver

Manager

Driver

Data

Source

Informix SybaseDB2

DriverDriver

Data

Source

Data

Source

OCIAPI

SQL*Net

Oracle

Data

Source

Page 11: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation11 DB-16: In Any Case, the Devil’s in the DataServer Details

Mary makes a house call

For Each

Display Cust

ABL

Hey Man …It’s all about the

“For Each”

OE DB OE DB

Page 12: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation12 DB-16: In Any Case, the Devil’s in the DataServer Details

Bravo !

Page 13: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation13 DB-16: In Any Case, the Devil’s in the DataServer Details

The End

Page 14: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation14 DB-16: In Any Case, the Devil’s in the DataServer Details

That was then …

For Each

Display Cust

ABL

OE DB OE DB

Page 15: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation15 DB-16: In Any Case, the Devil’s in the DataServer Details

Terminology & Technology Sync-up

OpenEdge

DatabaseOpenEdge

Database

Oracle

SQL ServerOracle

SQL Server

MS SQL

ServerMS SQL

Server

Page 16: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation16 DB-16: In Any Case, the Devil’s in the DataServer Details

Terminology & Technology Sync-up

OpenEdge

DatabaseOpenEdge

Database

Oracle

SQL ServerOracle

SQL Server

DataServer Broker

SQL

--

--

MS SQL

ServerMS SQL

Server

Page 17: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation17 DB-16: In Any Case, the Devil’s in the DataServer Details

Terminology & Technology Sync-up

OpenEdge

DatabaseOpenEdge

Database

INT CHAR

INT CHAR

1 J

2 Alsop

Oracle

SQL ServerOracle

SQL Server

INT VARCHAR2

5 L

6 Ellison

DataServer Broker

SQL

--

--

MS SQL

ServerMS SQL

Server

INT VARCHAR

3 B

4 Gates

Item

-no

Item

_no

Page 18: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation18 DB-16: In Any Case, the Devil’s in the DataServer Details

Terminology & Technology Sync-up

OpenEdge

DatabaseOpenEdge

Database

INT CHAR

INT CHAR

1 J

2 Alsop

Oracle

SQL ServerOracle

SQL Server

INT VARCHAR2

5 L

6 Ellison

DataServer Broker

SQL

--

--

MS SQL

ServerMS SQL

Server

INT VARCHAR

3 B

4 Gates

Item

-no

Item

_no

Page 19: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation19 DB-16: In Any Case, the Devil’s in the DataServer Details

Terminology & Technology Sync-up

OpenEdge

DatabaseOpenEdge

Database

INT CHAR

INT CHAR

1 J

2 Alsop

Oracle

SQL ServerOracle

SQL Server

INT VARCHAR2

5 L

6 Ellison

DataServer Broker

SQL

--

--

MS SQL

ServerMS SQL

Server

INT VARCHAR

3 B

4 Gates

Item

-no

Item

_no

Page 20: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation20 DB-16: In Any Case, the Devil’s in the DataServer Details

Sync-up: 4-Tier Perspective

OpenEdge

DatabaseOpenEdge

Database

Oracle

SQL ServerOracle

SQL Server

INT VARCHAR2

5 L

6 Ellison

DataServer Broker

SQL

--

--

MS SQL

ServerMS SQL

Server

INT VARCHAR

3 B

4 Gates INT CHAR

INT CHAR

1 J

2 Alsop

Page 21: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation21 DB-16: In Any Case, the Devil’s in the DataServer Details

Sync-up: Self-Service Client 3-Tier Perspective

Oracle

SQL ServerOracle

SQL Server

INT VARCHAR2

5 L

6 Ellison

MS SQL

ServerMS SQL

Server

INT VARCHAR

3 B

4 Gates

OpenEdge

DatabaseOpenEdge

Database

INT CHAR

INT CHAR

1 J

2 Alsop

Page 22: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation22 DB-16: In Any Case, the Devil’s in the DataServer Details

OpenEdge Client

DataServer

Sync-up: Application-centric

SELECT UPPERCASE (name) FROM Customer

FOR EACH Customer

Oracle

CBA

SELECT TO UPPER(name) FROM Customer

OpenEdge

DB2ZYX

321

SELECT TO UPPER(name) FROM Customer SELECT

UPPER(name) FROM Customer

---

---

---

Application Centric - Just another Oracle OCI or ODBC Client

SQL

Server

SQL

Server

OpenEdgeOpenEdgeSchema

PULL

Schema

PUSH

Page 23: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation23 DB-16: In Any Case, the Devil’s in the DataServer Details

Sync-up: Client-Server Perspective

Oracle

SQL ServerOracle

SQL Server

INT VARCHAR2

5 L

6 Ellison

MS SQL

ServerMS SQL

Server

INT VARCHAR

3 B

4 Gates

OpenEdge

DatabaseOpenEdge

Database

INT CHAR

INT CHAR

1 J

2 Alsop

DataServer Broker

SQL

--

--

Page 24: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation24 DB-16: In Any Case, the Devil’s in the DataServer Details

Sync-up: Component Perspective

OpenEdge

DatabaseOpenEdge

Database

Oracle

SQL ServerOracle

SQL Server

INT VARCHAR2

5 L

6 Ellison

MS SQL

ServerMS SQL

Server

INT VARCHAR

3 B

4 Gates

INT CHAR

INT CHAR

1 J

2 Alsop

Page 25: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation25 DB-16: In Any Case, the Devil’s in the DataServer Details

Sync-up: DataServer Component Layers

Progress ABL

Dataserver LayerDataserver Layer

Dataserver Client

Dataserver Server

MS SQL Srvr

ODBC

Oracle

OCI

Page 26: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation26 DB-16: In Any Case, the Devil’s in the DataServer Details

OpenEdge Reference ArchitectureFor Service Oriented Business Applications

Design for longevity, flexibility, and competitive advantage

PresentationPresentation

Business ComponentsBusiness Components

Data AccessData Access

Data SourcesData Sources

Co

mm

on

Infrastru

cture

Co

mm

on

Infrastru

cture

Enterprise ServicesEnterprise Services

Page 27: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation27 DB-16: In Any Case, the Devil’s in the DataServer Details

Case Study: Components

Page 28: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation28 DB-16: In Any Case, the Devil’s in the DataServer Details

Appreciate intricacies amongst components Demonstrate the somewhat “arbitrary”

diversity DataServer issues Create opportunities to discuss important

aspects of the DataServer architecture. Promote the interest of a problem-solver

audience

Case Study: Goals

Page 29: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation29 DB-16: In Any Case, the Devil’s in the DataServer Details

DataServer deference given to the database• On Security

• On Transaction Control

• On Lock Management

• On Cursor Consistency

Case Study: Prerequisite & Disclaimer

Page 30: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation30 DB-16: In Any Case, the Devil’s in the DataServer Details

I ran a pro-to-<dataserver> migration and compiled some code against the schema holder it built. Everything compiled just fine.

Then I built a separate schema holder, pulled definitions from the very same SQL database, and connected to it. But, against this schema holder, the compiled code fails.

Why would it matter how we create the schema holder as long as the structure of the SQL database remains exactly the same !

The Devils in the Details: Case Study #1

+ +

Page 31: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation31 DB-16: In Any Case, the Devil’s in the DataServer Details

DataServer Migration

OpenEdge

DatabaseOpenEdge

Database

INT CHAR

Oracle

SQL ServerOracle

SQL Server

INT VARCHAR2

5 L

6 Ellison

DataServer Broker

SQL

--

--

MS SQL

ServerMS SQL

Server

INT VARCHAR

3 B

4 Gates Item-no

Item_no

OpenEdge

DatabaseOpenEdge

Database

INT CHAR

1 J

2 Alsop

Item_no

Item-no

Page 32: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation32 DB-16: In Any Case, the Devil’s in the DataServer Details

Why don’t my schema holder “pull” definitions match the OpenEdge Database they were derived from ?

The script that built the SQL Database came directly from OpenEdge Database !

The Devils in the Details: Case Study #1 (cont.)

Page 33: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation33 DB-16: In Any Case, the Devil’s in the DataServer Details

DataServer Pushed & Pulled Independently

OpenEdge

DatabaseOpenEdge

Database

INT CHAR

Oracle

SQL ServerOracle

SQL Server

INT VARCHAR2

5 L

6 Ellison

DataServer Broker

SQL

--

--

MS SQL

ServerMS SQL

Server

INT VARCHAR

3 B

4 Gates Item_no

Item_no

OpenEdge

DatabaseOpenEdge

Database

INT CHAR

1 J

2 Alsop

Item_no

Item-no

Page 34: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation34 DB-16: In Any Case, the Devil’s in the DataServer Details

Pull & Adjust Schema

OpenEdge

DatabaseOpenEdge

Database

INT CHAR

Oracle

SQL ServerOracle

SQL Server

INT VARCHAR2

5 L

6 Ellison

DataServer Broker

SQL

--

--

MS SQL

ServerMS SQL

Server

INT VARCHAR

3 B

4 Gates Item-no

Item_no

OpenEdge

DatabaseOpenEdge

Database

INT CHAR

1 J

2 Alsop

Item_no

Item-no

Page 35: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation35 DB-16: In Any Case, the Devil’s in the DataServer Details

The Devils in the Details: Case Study #2

We deployed a new schema holder to our customers and their production applications started crashing with no warning. We didn’t make any code changes but if we do, the application still crashes, only with a different error.

What would cause the DataServer’s inconsistent behavior and how can we get an indication of the problem ?

+ ++

Page 36: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation36 DB-16: In Any Case, the Devil’s in the DataServer Details

The Devils in the Details: Case Study #3

I compiled my application against an OpenEdge Database. Then, I did the same against my Schema Holder. Why did the DataServer r-code grow larger than my OpenEdge database r-code ?

++

Page 37: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation37 DB-16: In Any Case, the Devil’s in the DataServer Details

The Devils in the Details: Case Study #4

During a migration, I’m getting truncation errors loading data into my SQL Server database . I elected the “load data” option. The schema copied fine but migrating data from my OpenEdge database to a DataServer schema holder fails. Why would the migration create definitions too small for my data ?

+ +

Page 38: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation38 DB-16: In Any Case, the Devil’s in the DataServer Details

The Devils in the Details: Case Study #5

I’m migrating an OpenEdge database to a DataServer schema. When I elect to load data, I get NULL-constraint and unique-constraint violations.

+ +

Page 39: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation39 DB-16: In Any Case, the Devil’s in the DataServer Details

Record Write & Availability

DEFINE BUFFER xcust FOR cust.CREATE cust.cust-num = 111.FIND xcust

WHERE xcust.cust-num = 111.

The Devils in the Details: Case Study #6 (Intro.)

+ +

Page 40: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation40 DB-16: In Any Case, the Devil’s in the DataServer Details

Record Write & Availability

DEFINE BUFFER xcust FOR cust.CREATE cust.cust-num = 111.VALIDATE cust. /* or RELEASE cust. */

FIND xcust WHERE xcust.cust-num = 111.

The Devils in the Details: Case Study #6 (Intro.)

+ +

Page 41: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation41 DB-16: In Any Case, the Devil’s in the DataServer Details

The Devils in the Details: Case Study #6

I’m getting a STOP condition trying to assign a column value after a FIND statement. The application exits after the ASSIGN. How can I be sure this isn’t corrupting my database ?

DO TRANSACTION:FIND FIRST cust.ASSIGN name = FILL(“a”,35) NO-ERROR.

END.

+ +

Page 42: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation42 DB-16: In Any Case, the Devil’s in the DataServer Details

The Devils in the Details: Case Study #6 (cont.)

+ +

But, I’m still getting the error condition

DO TRANSACTION:FIND FIRST cust.ASSIGN name = FILL(“a”,35)

NO-ERROR.VALIDATE cust.

END.

Page 43: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation43 DB-16: In Any Case, the Devil’s in the DataServer Details

The Devils in the Details: Case Study #6 (cont.)

+ +

DO TRANSACTION:FIND FIRST cust.ASSIGN name = FILL(“a”,35) /* NO-ERROR */.VALIDATE cust NO-ERROR.IF error-status:error THEN DO: <some error processing> UNDO, LEAVE.END.

END.

Page 44: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation44 DB-16: In Any Case, the Devil’s in the DataServer Details

The Devils in the Details: Case Study #6 (cont.)

+ +

But, I’m still getting the error condition

DO TRANSACTION ON ERROR UNDO,LEAVE:FIND FIRST cust.ASSIGN name = FILL(“a”,35) NO-ERROR.VALIDATE cust.

CATCH Progress.Lang.AppError ae: MESSAGE "Inside AppError Catch".

IF ae:GetMessage(1) <> ? THEN MESSAGE ae:GetMessage(1) ae:GetMessageNum(1).

ELSE MESSAGE "ReturnError" ae:returnvalue view-as alert-box.

DELETE OBJECT ae. END CATCH.

CATCH Progress.Lang.ProError pe: MESSAGE "Inside ProError Catch". REPEAT i = 1 TO pe:NumMessages: PUT UNFORMATTED " Error Number: " pe:GetMessageNum(i)

FORMAT ">>>>>9" SKIP "Message: " pe:GetMessage(i) FORMAT "x(73)" SKIP.

END. DELETE OBJECT pe. END CATCH.

END.

Page 45: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation45 DB-16: In Any Case, the Devil’s in the DataServer Details

The Devils in the Details: Case Study #6 (cont.)

+ +

Warning:

DO TRANSACTION:FIND FIRST cust EXCLUSIVE-LOCK.ASSIGN name = FILL(“a”,35) NO-ERROR.VALIDATE cust.

CONTENTION EXPOSURE !

END.

Page 46: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation46 DB-16: In Any Case, the Devil’s in the DataServer Details

The Devils in the Details: Case Study #7

I have two clients running simultaneously.Both create records and lock records exclusively on the same table. Why are they getting “table is use by another user” errors ?

DO TRANSACTION:FIND FIRST cust EXCLUSIVE-LOCK.IF AVAILABLE cust THEN ASSIGN name =

“Bob”. REPEAT:FIND NEXT cust EXCLUSIVE-LOCK.IF NOT AVAILABLE cust THEN LEAVE.Cnt = Cnt + 1.ASSIGN name = “Bob” + STRING(cnt).

END.END.

+ +

Page 47: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation47 DB-16: In Any Case, the Devil’s in the DataServer Details

The Devils in the Details: Case Study #7 (cont.)

DO TRANSACTION: FIND FIRST cust EXCLUSIVE-LOCK. IF AVAILABLE cust THEN ASSIGN name = “Bob”. REPEAT: DO TRANSACTION: FIND NEXT cust EXCLUSIVE-LOCK. IF NOT AVAILABLE cust THEN LEAVE. Cnt = Cnt + 1. ASSIGN name = “Bob” +

STRING(cnt). END. END. END.END.

+ +

Page 48: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation48 DB-16: In Any Case, the Devil’s in the DataServer Details

The Devils in the Details: Case Study #7 (cont.)

DO TRANSACTION:FIND FIRST cust EXCLUSIVE-LOCK.IF AVAILABLE cust THEN ASSIGN name = “Bob”.

END.REPEAT:

DO TRANSACTION: FIND NEXT cust EXCLUSIVE-LOCK. IF NOT AVAILABLE cust THEN LEAVE. Cnt = Cnt + 1. ASSIGN name = “Bob” +

STRING(cnt). END.

END.END.

+ +

Page 49: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation49 DB-16: In Any Case, the Devil’s in the DataServer Details

The Devils in the Details: Case Study #7 (cont.)

Another example regarding cursor consistency

DEFINE VARIABLE num AS INT INITIAL 103.DO TRANSACTION: FIND cust WHERE cust = num

EXCLUSIVE-LOCK. ASSIGN name = “Bob”.END.

FIND cust WHERE cust-num = num.DISPLAY name.

+ +

Page 50: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation50 DB-16: In Any Case, the Devil’s in the DataServer Details

The Devils in the Details: Case Study #8

Parenthesis around names in the WHERE clause of our join is [slow/fast], generates multiple queries and sends index hints with the queries.

• For each customer, each order WHERE (order.custnum) = (cust.custnum):

Oracle documentation says joins won’t pass index hints on a server join. If we just remove the parenthesis:

• For each customer, each order WHERE order.custnum = cust.custnum:

We only get one query, [better/worse] performance and no hints.

+

Page 51: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation51 DB-16: In Any Case, the Devil’s in the DataServer Details

The Devils in the Details: Case Study #9 - Part I

In our Oracle DataServer application, one of our users got a locked record error:

“<table> in use by <user> on <tty>. Wait or press CTRL-C to exit. (121)“

Pressing CTRL-C does not actually do anything. Our client script isn’t trapping CTRL-C, so what is ?

NOTE: stty on Unix shows Ctrl-C is mapped

+ +

Page 52: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation52 DB-16: In Any Case, the Devil’s in the DataServer Details

The Devils in the Details: Case Study #9 - Part II

Why did I get a “System Error 126” on Windows connecting through the ODBC DataServer ?

"Specified driver could not be loaded due to system error 126"

+ +

Page 53: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation53 DB-16: In Any Case, the Devil’s in the DataServer Details

Our Oracle DataServer application is running fine. Why does our application all of a sudden have a problem with an invalid cursor and then exit ?

The Devils in the Details: Case Study #10

++

Page 54: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation54 DB-16: In Any Case, the Devil’s in the DataServer Details

We migrated our legacy Oracle DataServer application from an earlier Progress implementation, that used “shadow columns”, to OpenEdge where it uses Function-based indexes. Why are we now seeing performance problems that appear to be related to Function Based Indexes ?

The Devils in the Details: Case Study #11

++

Page 55: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation55 DB-16: In Any Case, the Devil’s in the DataServer Details

DataServer Rule:

USE-INDEX and BY clauses affect the SQL ORDER BY clause. This guarantees the order of the results but does NOT guarantee the index selections of an execution plan.

The Devils in the Details: Case Study #11 (cont.)

++

Page 56: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation56 DB-16: In Any Case, the Devil’s in the DataServer Details

We’ve converted our legacy DB2/400 database to run against the ODBC DataServer. Some of our existing tables don’t have indexes so we describe indexes in the schema holder that satisfy the DataServer’s ROWID requirements. But when we display results for these tables, from a query like the following, why do some records show up twice in our result set ?

FOR EACH <table>:

DISPLAY <table>.

END.

The Devils in the Details: Case Study #12

++ +

Page 57: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation57 DB-16: In Any Case, the Devil’s in the DataServer Details

FOR EACH <table> SHARE-LOCK:

DISPLAY <table>.

END.

The Devils in the Details: Case Study #12 (cont.)

++ +

Page 58: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation58 DB-16: In Any Case, the Devil’s in the DataServer Details

FOR EACH <table> EXCLUSIVE-LOCK:

DISPLAY <table>.

END.

___________________________________

SELECT <columns> FROM <table> WHERE

<key-components> = <key-value>

-- or --

<RECID> = <recid-value>

The Devils in the Details: Case Study #12 (cont.)

++ +

Page 59: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation59 DB-16: In Any Case, the Devil’s in the DataServer Details

DataServer Rule:

Uniqueness is critical to proper functioning of DataServer cursors. Random access reads and all transactional activity is dependent on being able to locate an individual row.

The Devils in the Details: Case Study #12 (cont.)

++ +

Page 60: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation60 DB-16: In Any Case, the Devil’s in the DataServer Details

Why can’t data access through a DataServer be a fast as OpenEdge native access ?

The Devils in the Details: Performance Study

Page 61: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation61 DB-16: In Any Case, the Devil’s in the DataServer Details

FIND FIRST Customer NO-LOCK NO-ERROR.IF AVAILABLE Customer THEN Cnt = 1.REPEAT: FIND NEXT Customer NO-ERROR. IF NOT AVAILABLE (Customer) THEN LEAVE. Cnt = Cnt + 1.END.

OPEN QUERY q FOR EACH Customer NO-LOCK.REPEAT: GET NEXT q. IF NOT AVAILABLE Customer THEN LEAVE. Cnt = Cnt + 1.END.CLOSE QUERY q.

The Devils in the Details: Performance Study

Page 62: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation62 DB-16: In Any Case, the Devil’s in the DataServer Details

Replace FIND statements with FORs & QUERYs• FIND FIRST customer -> FOR FIRST customer: END. • FIND LAST order -> bBuffer:FIND-LAST().

Be explicit about lock type

Field Lists• FOR EACH customer FIELDS(cust-num name) NO-LOCK:• Make sure to include all fields you reference. This compiles:

FIND FIRST customer FIELDS(cust-num) WHERE CAN-FIND(FIRST order WHERE order.st = cust.st)

Write JOIN-BY-SQLDB queries• FOR EACH customer, EACH order:

Index Reposition• OPEN QUERY q1 FOR EACH order INDEXED-REPOSITION• REPOSITION q1 to recid myid

The Devils in the Details: Performance Study

Page 63: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation63 DB-16: In Any Case, the Devil’s in the DataServer Details

Query structure• Don’t get fancy

– WHERE (city + STRING(“,”) + state) = …– Complex joins may require a client join or client

selection

• WHERE col1 = INTEGER(‘123’) is better than WHERE STRING(col1) = “123”

• Try to make your BY clause and the expected INDEX selection compatible to avoid reordering: WHERE col1 = <> AND col2 = <> By col1, BY col2

The Devils in the Details: Performance Study

Page 64: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation64 DB-16: In Any Case, the Devil’s in the DataServer Details

Query Tuning• CACHE-SIZE(<size>)• REVERSE-FROM• (no-index-hint hint “run fast”)• NO-BIND-WHERE• NO-UNIQUE-ORDER-ADDED

Database Optimizations• Indexes, covering idx’s (clustered idx (MSS) &

“included” columns– MSS2005)• Updated Statistics• Index rebuild/reorg & Fill Factors, etc.

The Devils in the Details: Performance Study

Page 65: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation65 DB-16: In Any Case, the Devil’s in the DataServer Details

Remember you can always conditionalize:• Compile Time

&GLOBAL-DEFINE DB-TYPE ORACLE&IF DEFINED ({&ORACLE}) &THEN …

• Run TimeIF DBTYPE(dbname) = “PROGRESS” THEN RUN OpenEdge-optimized-code

• ELSE RUN DataServer-optimized-code

The Devils in the Details: Performance Study

Page 66: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation66 DB-16: In Any Case, the Devil’s in the DataServer Details

Use stored procedures:

• RUN STORED-PROC send-sql-statement hdl1 = PROC-HANDLE (“select name, cust_num FROM customer”).FOR EACH proc-text-buffer WHERE PROC-HANDLE = hdl1: DISPLAY proc-text.END.CLOSE STORED-PROC send-sql-statement rtn-stat = PROC-STATUS WHERE PROC-HANDLE = hdl1.

• DEF VAR ttHndl AS HANDLEDEF TEMP-TABLE tt1 ….ttHndl = TEMP-TABLE tt1:HANDLE.RUN STORED-PROC send-sql-statement (“select name, cust_num FROM customer”) LOAD-RESULT-INTO ttHndl.

• DEF VAR ttHndl AS HANDLE EXTENT 2.DEF TEMP-TABLE tt1 … ttHndl[1] = TEMP-TABLE tt1:HANDLE.DEF TEMP-TABLE tt2 … ttHndl[2] = TEMP-TABLE tt2:HANDLE.RUN STORED-PROC send-sql-statement (“select name FROM customer; select order-num FROM order”) LOAD-RESULT-INTO ttHndl.

The Devils in the Details: Performance Study

Page 67: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation67 DB-16: In Any Case, the Devil’s in the DataServer Details

In Summary

Know thy Client Component (ABL & DataServer)

Know thy access component (drivers & configuration)

Know thy database component (data manager & engine)

Page 68: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation68 DB-16: In Any Case, the Devil’s in the DataServer Details

For More Information, go to…

PSDN

• “DataServer Best Practices”• http://www.psdn.com/library/servlet/KbServlet/

download/1320-102-620/ds_best_practices.pdf

Exchange 07:• DB-21 Data Management and Platforms

Roadmap and Info Exchange

(Wednesday 1:30-3:00 Room #200)

Page 69: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation69 DB-16: In Any Case, the Devil’s in the DataServer Details

Questions?

Page 70: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation70 DB-16: In Any Case, the Devil’s in the DataServer Details

Thank you for your time!

Page 71: DB-16: In Any Case, the Devil’s in the DataServer Details

© 2007 Progress Software Corporation71 DB-16: In Any Case, the Devil’s in the DataServer Details