![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
DB2 v8 FP2 Red Hat Linux 7.3 I have a large (well, I think its large) <table> containing around 100 million rows. When I do a select count(*) from <table either from JDBC or from the DB2 CLP, things just hang. It never comes back. Any other queries against the table are pronto, so its not a locked table or anything. I have 2 unique indexes against the table. I have run stats against the table a LOT... This should be instant. Any idea whats happening? thanks Allen |
#2
| |||
| |||
|
|
DB2 v8 FP2 Red Hat Linux 7.3 I have a large (well, I think its large) <table> containing around 100 million rows. When I do a select count(*) from <table either from JDBC or from the DB2 CLP, things just hang. It never comes back. Any other queries against the table are pronto, so its not a locked table or anything. I have 2 unique indexes against the table. I have run stats against the table a LOT... This should be instant. Any idea whats happening? thanks Allen |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
On Thu, 21 Aug 2003 21:45:53 +0000, allen wrote: DB2 v8 FP2 Red Hat Linux 7.3 I have a large (well, I think its large) <table> containing around 100 million rows. When I do a select count(*) from <table I'm not surprised it's taking some time : you're having to read through the whole table to return a count of all the rows. All you can do is try to make the count go as fast as possible by throwing as much hardware and parallelism at it as possible. I assume you're not considering such as statement for production ? If you were then maybe time to reconsider !!! If so, do you really need the count 100% accurate. If not, then pick up the ballpark figure from the catalog (CARDF on SYSIBM.SYSTABLES I think). This of course assumes that you've run RUNSTATS recently. |
#5
| |||
| |||
|
|
DB2 v8 FP2 Red Hat Linux 7.3 I have a large (well, I think its large) <table> containing around 100 million rows. When I do a select count(*) from <table either from JDBC or from the DB2 CLP, things just hang. It never comes back. Any other queries against the table are pronto, so its not a locked table or anything. I have 2 unique indexes against the table. I have run stats against the table a LOT... This should be instant. Any idea whats happening? thanks Allen |
#6
| |||
| |||
|
#7
| |||
| |||
|
|
I don't think a table scan is needed. It's suffient to scan any index (ideally the smallest) |
#8
| |||
| |||
|
|
Only if you do db2set DB2_THUMB_RULE = YES; *tongue firmly in cheek* Cheers Serge |
#9
| |||
| |||
|
|
#Columns = 0 Relation Scan | Prefetch: Eligible Lock Intents | Table: Intent Share | Row : Next Key Share Predicate Aggregation | Column Function(s) Aggregation Completion Column Function(s) Return Data to Application #Columns = 1 |
|
#Columns = 0 Index Scan: Name = DBOXS.X01LINEITEM ID = 1 | Regular Index (Clustered) | Index Columns: | | 1: L_ORDERKEY (Ascending) | #Key Columns = 0 | | Start Key: Beginning of Index | | Stop Key: End of Index | Index-Only Access | Index Prefetch: Eligible 1412 | Predicate Aggregation | | Column Function(s) Lock Intents | Table: Intent Share | Row : Next Key Share Aggregation Completion Column Function(s) Return Data to Application #Columns = 1 |
#10
| |||
| |||
|
|
DB2 v8 FP2 Red Hat Linux 7.3 I have a large (well, I think its large) <table> containing around 100 million rows. When I do a select count(*) from <table either from JDBC or from the DB2 CLP, things just hang. It never comes back. Any other queries against the table are pronto, so its not a locked table or anything. I have 2 unique indexes against the table. |
![]() |
| Thread Tools | |
| Display Modes | |
| |