在分布式数据库的查询中,一般远程查询数据的过滤是在远程数据库进行的,仅仅将过滤后的
结果返回到本地,本地再进行相应的处理。
譬如SELECT * FROM WHERE ID=1
ID=1过滤的进行将会在REMOTEDB端进行。
但是这个并不是绝对的,如果WHERE条件里用了一些变化的函数,譬如SYSDATE,那么过滤将会在本地进行,
数据将会从远程传输到本地,本地完成过滤。
也就是因为这个问题,在我从INFORMIX数据库迁移到ORACLE中,让我苦苦等了2个小时。
- SQL> set timing on
- SQL> select count(1) from "test"@informix;
- COUNT(1)
- ----------
- 44744817
- Elapsed: 00:00:00.00
- SQL> select count(*)
- 2 from "test"@informix
- 3 where "deskdate" > to_date('20120910','yyyymmdd');
- COUNT(*)
- ----------
- 92
- Elapsed: 00:00:00.00
正常情况下采用常量不到1秒就可以查询出来。
而且网卡的流量也很小。
10:16:06 AM IFACE rxpck/s txpck/s rxbyt/s txbyt/s rxcmp/s txcmp/s rxmcst/s
10:16:10 AM lo 0.50 0.50 25.00 25.00 0.00 0.00 0.00
10:16:10 AM eth0 3.00 0.00 342.00 0.00 0.00 0.00 2.25
10:16:10 AM sit0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
10:16:10 AM IFACE rxpck/s txpck/s rxbyt/s txbyt/s rxcmp/s txcmp/s rxmcst/s
10:16:14 AM lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
10:16:14 AM eth0 4.25 0.75 353.50 167.50 0.00 0.00 3.50
10:16:14 AM sit0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
10:16:14 AM IFACE rxpck/s txpck/s rxbyt/s txbyt/s rxcmp/s txcmp/s rxmcst/s
10:16:18 AM lo 6.00 6.00 534.75 534.75 0.00 0.00 0.00
10:16:18 AM eth0 7.25 5.00 640.25 515.75 0.00 0.00 3.50
10:16:18 AM sit0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
10:16:18 AM IFACE rxpck/s txpck/s rxbyt/s txbyt/s rxcmp/s txcmp/s rxmcst/s
10:16:22 AM lo 1.25 1.25 288.00 288.00 0.00 0.00 0.00
10:16:22 AM eth0 5.75 2.25 505.00 317.50 0.00 0.00 2.75
10:16:22 AM sit0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
10:16:22 AM IFACE rxpck/s txpck/s rxbyt/s txbyt/s rxcmp/s txcmp/s rxmcst/s
10:16:26 AM lo 13.25 13.25 2901.75 2901.75 0.00 0.00 0.00
10:16:26 AM eth0 24.75 22.00 4202.50 4342.50 0.00 0.00 3.00
10:16:26 AM sit0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
10:16:26 AM IFACE rxpck/s txpck/s rxbyt/s txbyt/s rxcmp/s txcmp/s rxmcst/s
10:16:30 AM lo 46.50 46.50 10790.25 10790.25 0.00 0.00 0.00
10:16:30 AM eth0 61.00 59.25 8592.25 9220.50 0.00 0.00 4.00
10:16:30 AM sit0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
如果将to_date('20120910','yyyymmdd')换成sysdate,那么查询时间将会是原来的N倍。
- SQL> select count(*)
- 2 from "test"@informix
- 3 where "deskdate" > trunc(sysdate);
- COUNT(*)
- ----------
- 92
- Elapsed: 00:03:45.80
用了将近4分钟。
而且网卡的流量也非常高。
10:17:14 AM IFACE rxpck/s txpck/s rxbyt/s txbyt/s rxcmp/s txcmp/s rxmcst/s
10:17:18 AM lo 197.74 197.74 1015475.69 1015475.69 0.00 0.00 0.00
10:17:18 AM eth0 1294.74 1289.22 1640551.38 78949.37 0.00 0.00 2.51
10:17:18 AM sit0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
10:17:18 AM IFACE rxpck/s txpck/s rxbyt/s txbyt/s rxcmp/s txcmp/s rxmcst/s
10:17:22 AM lo 301.25 301.25 1565779.80 1565779.80 0.00 0.00 0.00
10:17:22 AM eth0 1709.48 1704.49 2177423.19 103304.99 0.00 0.00 2.00
10:17:22 AM sit0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
10:17:22 AM IFACE rxpck/s txpck/s rxbyt/s txbyt/s rxcmp/s txcmp/s rxmcst/s
10:17:26 AM lo 319.75 319.75 1670846.25 1670846.25 0.00 0.00 0.00
10:17:26 AM eth0 1789.25 1783.75 2268852.25 111667.50 0.00 0.00 2.75
10:17:26 AM sit0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
10:17:26 AM IFACE rxpck/s txpck/s rxbyt/s txbyt/s rxcmp/s txcmp/s rxmcst/s
10:17:30 AM lo 301.25 301.25 1569655.25 1569655.25 0.00 0.00 0.00
10:17:30 AM eth0 1695.25 1688.00 2158884.50 101395.00 0.00 0.00 4.25
10:17:30 AM sit0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
10:17:30 AM IFACE rxpck/s txpck/s rxbyt/s txbyt/s rxcmp/s txcmp/s rxmcst/s
10:17:34 AM lo 329.75 329.75 1721554.00 1721554.00 0.00 0.00 0.00
10:17:34 AM eth0 1866.75 1862.50 2377286.25 113130.75 0.00 0.00 2.00
10:17:34 AM sit0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
10:17:34 AM IFACE rxpck/s txpck/s rxbyt/s txbyt/s rxcmp/s txcmp/s rxmcst/s
10:17:38 AM lo 312.03 312.03 1624365.91 1624365.91 0.00 0.00 0.00
10:17:38 AM eth0 1783.21 1776.44 2268080.45 108688.47 0.00 0.00 4.51
10:17:38 AM sit0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
10:17:38 AM IFACE rxpck/s txpck/s rxbyt/s txbyt/s rxcmp/s txcmp/s rxmcst/s
10:17:42 AM lo 317.21 317.21 1666587.78 1666587.78 0.00 0.00 0.00
10:17:42 AM eth0 1775.81 1770.07 2263793.52 106349.63 0.00 0.00 2.24
10:17:42 AM sit0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
阅读(1844) | 评论(0) | 转发(0) |