Your SlideShare is downloading. ×
Distributed Queries in IDS:  New features in IDS. Keshava Murthy,  Architect, Informix Software.  IBM,  [email_address] Se...
<ul><li>Introduction to distributed query </li></ul><ul><li>Configuring IDS for distributed queries </li></ul><ul><li>What...
inventorydb Application Application IDS Server:  order_server IDS Server: eduserver Application orderdb payrolldb edudb CR...
inventorydb Application Application order_server  orderdb emp_server empdb Application orderdb payrolldb edudb CROSS-SERVE...
Scenarios to use distributed queries. <ul><li>Need to access the latest data. </li></ul><ul><li>Centralized control </li><...
When to use distributed queries. <ul><li>Real time data access and modification. </li></ul><ul><li>Reliable data access an...
CROSS-SERVER SELECT p.empid, o.orderid, o.orderdesc FROM  payrolldb@emp_server:employees e,   orderdb@order_server:course ...
sqlhosts <ul><li>Inventorysrv  onsoctcp  myinv.domaon.com 5463 </li></ul><ul><li>orderserver  onsoctcp  9.48.52.345  4526 ...
<ul><li>QUERY: </li></ul><ul><li>------ </li></ul><ul><li>SELECT t.col1 FROM orderby@server1:tab1 t ORDER BY t.col2 </li><...
<ul><li>QUERY: </li></ul><ul><li>------ </li></ul><ul><li>select a1.t1c2, a2.t2c2, a3.t3c2, a4.t4c2 </li></ul><ul><li>from...
Informix Dynamic Server Datatypes SET Complex Datatypes Basic SQL Types Numeric Character Time Large Objects Extended Data...
Built-in SQL Datatypes Character Numeric LargeObjects Time <ul><li>Char </li></ul><ul><li>Varchar </li></ul><ul><li>Nchar ...
Built-in Extended types <ul><li>Boolean </li></ul><ul><li>LVARCHAR </li></ul><ul><li>BLOB </li></ul><ul><li>CLOB </li></ul>
Cross-Database Queries – one server <ul><li>IDS v10 and above </li></ul><ul><li>New Extended Data types support </li></ul>...
Cross-Database Queries – one server <ul><li>IDS v10 and above </li></ul><ul><li>New types can be used in </li></ul><ul><ul...
Cross Database example: SELECT <ul><li>DATABASE orderdb; </li></ul><ul><li>SELECT item_num,item_desc,item_specs,item_pic,i...
Cross Database example: INSERT <ul><li>Insert on Remote table having built-in udts </li></ul><ul><li>INSERT INTO remotedb:...
Cross Database example: UPDATE/DELETE <ul><li>DATABASE orderdb; </li></ul><ul><li>UPDATE inventorydb:itemtab </li></ul><ul...
Cross Database example: CREATE VIEW <ul><li>DATABASE orderdb; </li></ul><ul><li>CREATE VIEW item_pk_view AS </li></ul><ul>...
CROSS-SERVER SELECT p.empid, o.orderid, o.orderdesc FROM  payrolldb@emp_server:employees e,   orderdb@order_server:course ...
Enhancements in IDS v11.10 <ul><li>Cross-Server queries now support </li></ul><ul><ul><li>Boolean </li></ul></ul><ul><ul><...
Builtin-extended Boolean, lvarchar,  blob, clob Informix Dynamic Server Datatypes SET Complex Datatypes Basic SQL Types Nu...
Application IDS Server:  lenexa Database: geardb Table: winter_gear  with Boolean, lvarchar and distinct types C, SPL, Jav...
<ul><li>Connect to  Menlo : </li></ul><ul><li>CREATE TABLE sunny_gear(partner int, active Boolean, desc lvarchar(4096)); <...
Enhancements to distributed Explain. <ul><li>Explain file explains the query plan chosen by optimizer </li></ul><ul><li>Th...
<ul><li>On the coordinator </li></ul><ul><li>QUERY: </li></ul><ul><li>------ </li></ul><ul><li>SELECT rt1.col1 FROM orderb...
<ul><li>Thank You </li></ul><ul><li>[email_address] </li></ul><ul><li>Session: 2988A </li></ul>
Upcoming SlideShare
Loading in...5
×

Distributed Queries in IDS: New features.

1,446

Published on

Learn about the latest function relating to distributed queries that was delivered in IBM Informix® Dynamic Server (IDS) 11 and 11.5. This talk will provide an overview of distributed queries, then will jump into a deep dive on the latest functions and how you can benefit from implementing distributed queries in your solutions.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,446
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Distributed Queries in IDS: New features."

  1. 1. Distributed Queries in IDS: New features in IDS. Keshava Murthy, Architect, Informix Software. IBM, [email_address] Session Number 2988
  2. 2. <ul><li>Introduction to distributed query </li></ul><ul><li>Configuring IDS for distributed queries </li></ul><ul><li>What’s new in IDS v10 and v11 </li></ul><ul><li>Enhancements in IDS v10 </li></ul><ul><li>Enhancements in IDS v11 </li></ul><ul><li>Future directions and feedback </li></ul>
  3. 3. inventorydb Application Application IDS Server: order_server IDS Server: eduserver Application orderdb payrolldb edudb CROSS-Database SELECT o.ordid, i.invdesc FROM orderdb:orders o , inventorydb:inventory i Where o.customerid = 1234 and o.ordinvid = i.invid; CROSS-Database SELECT p.empid, c.course FROM payrolldb:employees e, edudb:course c WHERE p.empid = 1234 And p.courseid = c.coursid
  4. 4. inventorydb Application Application order_server orderdb emp_server empdb Application orderdb payrolldb edudb CROSS-SERVER SELECT p.empid, o.orderid, o.orderdesc FROM payrolldb@emp_server:employees e, orderdb@order_server:course c WHERE e.empid = 1234 And e.courseid = c.coursid
  5. 5. Scenarios to use distributed queries. <ul><li>Need to access the latest data. </li></ul><ul><li>Centralized control </li></ul><ul><li>Data is in different systems – be in same or different location. </li></ul><ul><li>Data can be in multiple version of IDS or XPS </li></ul><ul><ul><li>Data integration </li></ul></ul><ul><ul><li>Heterogeneous data base systems. </li></ul></ul>
  6. 6. When to use distributed queries. <ul><li>Real time data access and modification. </li></ul><ul><li>Reliable data access and modifications. </li></ul><ul><li>Need full 2-phase commit support </li></ul><ul><ul><li>Used by the transaction manager at the co-ordinator </li></ul></ul><ul><ul><li>Commit phase goes thru 2 phases </li></ul></ul><ul><ul><li>1 st phase: PREPARE to COMMIT </li></ul></ul><ul><ul><li>2 nd phase: commit if all the polled servers are OK. </li></ul></ul>
  7. 7. CROSS-SERVER SELECT p.empid, o.orderid, o.orderdesc FROM payrolldb@emp_server:employees e, orderdb@order_server:course c WHERE e.empid = 1234 And e.courseid = c.coursid inventorydb order_server:orderdb orderdb server2 server3 server5 server4
  8. 8. sqlhosts <ul><li>Inventorysrv onsoctcp myinv.domaon.com 5463 </li></ul><ul><li>orderserver onsoctcp 9.48.52.345 4526 </li></ul>Informix server name Network protocol IP address Port number
  9. 9. <ul><li>QUERY: </li></ul><ul><li>------ </li></ul><ul><li>SELECT t.col1 FROM orderby@server1:tab1 t ORDER BY t.col2 </li></ul><ul><li>Estimated Cost: 1 </li></ul><ul><li>Estimated # of Rows Returned: 1 </li></ul><ul><li>Temporary Files Required For: Order By </li></ul><ul><li>1) sqlqa.t: SEQUENTIAL SCAN </li></ul><ul><li>QUERY: </li></ul><ul><li>------ </li></ul><ul><li>SELECT rt1.col1 FROM orderby@server2:tab1 rt1 ORDER BY rt1.col2 </li></ul><ul><li>Estimated Cost: 1 </li></ul><ul><li>Estimated # of Rows Returned: 1 </li></ul><ul><li>1) sqlqa.rt1: REMOTE PATH </li></ul><ul><li>Remote SQL Request: </li></ul><ul><li>select x0.col1 from orderby:&quot;sqlqa&quot;.tab1 x0 order by x0.col2 </li></ul>
  10. 10. <ul><li>QUERY: </li></ul><ul><li>------ </li></ul><ul><li>select a1.t1c2, a2.t2c2, a3.t3c2, a4.t4c2 </li></ul><ul><li>from (rdb2@server2:t1 a1 left join rdb2@server2:t2 a2 </li></ul><ul><li>on a1.t1c1 = a2.t2c1) </li></ul><ul><li>cross join (rdb2@server2:t3 a3 left join rdb2@server2:t4 a4 </li></ul><ul><li>on a3.t3c1 = a4.t4c1) </li></ul><ul><li>Estimated Cost: 7 </li></ul><ul><li>Estimated # of Rows Returned: 11 </li></ul><ul><li>1) sqlqa.a3, sqlqa.a4: REMOTE PATH </li></ul><ul><li>Remote SQL Request: </li></ul><ul><li>select x0.t3c1 ,x0.t3c2 ,x1.t4c1 ,x1.t4c2 from (rdb2:&quot;sqlqa&quot;.t3 </li></ul><ul><li>x0 left join rdb2:&quot;sqlqa&quot;.t4 x1 on (x0.t3c1 = x1.t4c1 ) ) </li></ul><ul><li>2) sqlqa.a1, sqlqa.a2: REMOTE PATH </li></ul><ul><li>Remote SQL Request: </li></ul><ul><li>select x2.t1c1 ,x2.t1c2 ,x3.t2c1 ,x3.t2c2 from ((rdb2:&quot;sqlqa&quot;.t1 </li></ul><ul><li>x2 left join rdb2:&quot;sqlqa&quot;.t2 x3 on (x2.t1c1 = x3.t2c1 ) )) </li></ul><ul><li>NESTED LOOP JOIN </li></ul>
  11. 11. Informix Dynamic Server Datatypes SET Complex Datatypes Basic SQL Types Numeric Character Time Large Objects Extended Data types Collection Row Types Multi-Set List Distinct Builtin-extended Boolean, lvarchar, blob, clob opaque User Defined Datatypes
  12. 12. Built-in SQL Datatypes Character Numeric LargeObjects Time <ul><li>Char </li></ul><ul><li>Varchar </li></ul><ul><li>Nchar </li></ul><ul><li>Nvarchar </li></ul><ul><li>Int </li></ul><ul><li>Int8 </li></ul><ul><li>float </li></ul><ul><li>Decimal </li></ul><ul><li>Numeric </li></ul><ul><li>Money </li></ul><ul><li>Smallint </li></ul><ul><li>Smallfloat </li></ul><ul><li>Serial </li></ul><ul><li>Serial8 </li></ul><ul><li>Bigint </li></ul><ul><li>Bigserial </li></ul><ul><li>datetime </li></ul><ul><li>Interval </li></ul><ul><li>date </li></ul><ul><li>Text </li></ul><ul><li>Byte </li></ul>
  13. 13. Built-in Extended types <ul><li>Boolean </li></ul><ul><li>LVARCHAR </li></ul><ul><li>BLOB </li></ul><ul><li>CLOB </li></ul>
  14. 14. Cross-Database Queries – one server <ul><li>IDS v10 and above </li></ul><ul><li>New Extended Data types support </li></ul><ul><li>Built-in UDTS across databases, single server instance </li></ul><ul><ul><li>BOOLEAN </li></ul></ul><ul><ul><li>LVARCHAR </li></ul></ul><ul><ul><li>BLOB </li></ul></ul><ul><ul><li>CLOB </li></ul></ul><ul><li>Non built-in UDTS across databases in a single server instance, with explicit cast to LVARCHAR </li></ul><ul><li>Boolean, LVARCHAR, BLOB and CLOB are commonly used in applications. </li></ul>
  15. 15. Cross-Database Queries – one server <ul><li>IDS v10 and above </li></ul><ul><li>New types can be used in </li></ul><ul><ul><li>Direct DML </li></ul></ul><ul><ul><li>Views </li></ul></ul><ul><ul><li>Synonyms </li></ul></ul><ul><ul><li>Stored procedure parameters and return types </li></ul></ul><ul><ul><li>C and Java UDRs </li></ul></ul>
  16. 16. Cross Database example: SELECT <ul><li>DATABASE orderdb; </li></ul><ul><li>SELECT item_num,item_desc,item_specs,item_pic,item_life </li></ul><ul><li>FROM inventorydb:itemtab </li></ul><ul><li>WHERE item_num = 1; </li></ul><ul><li>SELECT item_sm_pk::LVARCHAR,item_lg_pk::varchar </li></ul><ul><li>FROM inventorydb:itemtab </li></ul><ul><li>WHERE item_num = 2; </li></ul>
  17. 17. Cross Database example: INSERT <ul><li>Insert on Remote table having built-in udts </li></ul><ul><li>INSERT INTO remotedb:remtab </li></ul><ul><li>(boolean_col, lvarchar_col, blob_col, clob_col) </li></ul><ul><li>VALUES (‘t’, “lvarchar_data”, Filetoblob(‘blobfile’, ‘client’), </li></ul><ul><li>Filetoclob(‘clobfile’, ‘client’)) </li></ul><ul><li>Insert into remote table Select from local table built-in udts </li></ul><ul><li>INSERT INTO remotedb:remtab </li></ul><ul><li>( boolean_col, lvarchar_col, blob_col, clob_col) </li></ul><ul><li>SELECT bool_col, lvar_col, b_col, c_col </li></ul><ul><li>FROM local_tab </li></ul><ul><li>WHERE bool_col = “t”; </li></ul><ul><li>Insert on Remote table non built-in UDTs </li></ul><ul><li>INSERT INTO remotedb:remtab (udt1_col) </li></ul><ul><li>SELECT udt_col::lvarchar </li></ul><ul><li>FROM local_tab </li></ul><ul><li>WHERE udt2_col::lvarchar = “ldata2row1”; </li></ul>
  18. 18. Cross Database example: UPDATE/DELETE <ul><li>DATABASE orderdb; </li></ul><ul><li>UPDATE inventorydb:itemtab </li></ul><ul><li>SET (item_lg_pk) = </li></ul><ul><li>((SELECT order_lg_pk::lvarcharFROM ordertab </li></ul><ul><li>WHERE order_sm_pk::lvarchar = &quot;box(2,2,2,2)&quot;)) </li></ul><ul><li>WHERE order_shelf_life = &quot;t&quot;; </li></ul>
  19. 19. Cross Database example: CREATE VIEW <ul><li>DATABASE orderdb; </li></ul><ul><li>CREATE VIEW item_pk_view AS </li></ul><ul><li>SELECT item_lg_pk::lvarchar, </li></ul><ul><li>item_sm_pk::varchar </li></ul><ul><li>FROM inventorydb:itemtab </li></ul><ul><li>WHERE item_sm_pk::char matches &quot;box(2,2,2,2)*&quot; </li></ul>
  20. 20. CROSS-SERVER SELECT p.empid, o.orderid, o.orderdesc FROM payrolldb@emp_server:employees e, orderdb@order_server:course c WHERE e.empid = 1234 And e.courseid = c.coursid Cross Server inventorydb order_server:orderdb orderdb server2 server3 server5 server4
  21. 21. Enhancements in IDS v11.10 <ul><li>Cross-Server queries now support </li></ul><ul><ul><li>Boolean </li></ul></ul><ul><ul><li>Lvarchar </li></ul></ul><ul><ul><li>Distinct types of Boolean and Lvarchar </li></ul></ul><ul><ul><li>Distinct types of built-in SQL types </li></ul></ul><ul><ul><ul><li>Numeric (int, decimal, etc) </li></ul></ul></ul><ul><ul><ul><li>character (char, varchar, etc) </li></ul></ul></ul><ul><ul><ul><li>Time (datetime) </li></ul></ul></ul><ul><ul><li>No support for blob and clob yet </li></ul></ul>
  22. 22. Builtin-extended Boolean, lvarchar, blob, clob Informix Dynamic Server Datatypes SET Complex Datatypes Basic SQL Types Numeric Character Time Large Objects Extended Data types User Defined Datatypes Collection Row Types Multi-Set List Distinct Opaque
  23. 23. Application IDS Server: lenexa Database: geardb Table: winter_gear with Boolean, lvarchar and distinct types C, SPL, Java functions IDS Server: portland Database:geardb Table: rain_gear with Boolean, lvarchar, and distinct types C, SPL, Java functions IDS Server: menlo Database: geardb Table: winter_gear with Boolean, lvarchar and distinct types C, SPL, Java functions ISTAR: Distributed query connections SQL and result set exchange Multiple IDS server setup IDS Server: toronto Database:geardb C, SPL, Java functions
  24. 24. <ul><li>Connect to Menlo : </li></ul><ul><li>CREATE TABLE sunny_gear(partner int, active Boolean, desc lvarchar(4096)); </li></ul><ul><li>-- Select active partners at (Menlo, Lenexa and Portland) </li></ul><ul><li>SELECT x.partner, x.desc, y.desc, z.desc </li></ul><ul><li>FROM geardb@menlo:sunny_gear x, </li></ul><ul><li>geardb@portland:rain_gear y, </li></ul><ul><li>geardb@lenexa:winter_gear z </li></ul><ul><li>WHERE x.partner = y.partner and </li></ul><ul><li>x.partner = z.partner and </li></ul><ul><li>x.active = ‘T’ and </li></ul><ul><li>y.active = ‘T’ and </li></ul><ul><li>z.active = ‘T’ </li></ul><ul><li>ORDER BY x.partner; </li></ul>
  25. 25. Enhancements to distributed Explain. <ul><li>Explain file explains the query plan chosen by optimizer </li></ul><ul><li>The explain file at co-ordinator provides the session ID at the sub-ordinator </li></ul><ul><li>If the explain is ON at the co-ordinator, subordinator automatically generates the explain file. </li></ul><ul><li>Can be disabled by DISTR_QUERY_FLAGS </li></ul><ul><ul><li>0x01 enable or disable the distributed query plan </li></ul></ul><ul><ul><li>0x02 enable the statistics in the explain file. </li></ul></ul><ul><li>See the online.log for the exact location of the explain file. </li></ul>
  26. 26. <ul><li>On the coordinator </li></ul><ul><li>QUERY: </li></ul><ul><li>------ </li></ul><ul><li>SELECT rt1.col1 FROM orderby@server2:tab1 rt1 ORDER BY rt1.col2 </li></ul><ul><li>Estimated Cost: 1 </li></ul><ul><li>Estimated # of Rows Returned: 1 </li></ul><ul><li>1) sqlqa.rt1: REMOTE PATH </li></ul><ul><li> Remote Server name: server2 </li></ul><ul><li> Remote Session id: 6 </li></ul><ul><li>Remote SQL Request: </li></ul><ul><li>select x0.col1 from orderby:&quot;sqlqa&quot;.tab1 x0 order by x0.col2 </li></ul><ul><li>On the subordinator: </li></ul><ul><li>09:19:34 Explain file for session 6 : usr/appusr1/sqexplain.out.6 </li></ul>
  27. 27. <ul><li>Thank You </li></ul><ul><li>[email_address] </li></ul><ul><li>Session: 2988A </li></ul>

×