![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
... a reorg/runstats speeds it up ... Do you have indexes on tables? |
#3
| |||
| |||
|
|
I am running DB2 V9.5 on AIX. *We have a fairly small database (2 million records max on main table). *We use COUNT(*) periodically. *We also schedule runstats and online reorg periodically. *At times COUNT(*) can be very slow and although a reorg/runstats speeds it up we can have a window when the count is needed but reorg/runstats has not yet run. *Also, I cannot run reorg/runstats at the time a count is requested since it would take longer to do it than it would be to just wait for the count to return. Any suggestions on what else can be used to get the count of a table? The cardinality isnt accurante until a runstats is done so that is not useful. *Is there a quick "rowcount" type way to get this info? *I just need a speedy way to get number of records. |
#4
| |||
| |||
|
|
... a reorg/runstats speeds it up ... Do you have indexes on tables? How long time is allowed to get number of 2 million records max on main table? |
#5
| |||
| |||
|
|
On Feb 15, 5:24 pm, Tonkuma<tonk... (AT) fiberbit (DOT) net> wrote: ... a reorg/runstats speeds it up ... Do you have indexes on tables? How long time is allowed to get number of 2 million records max on main table? Yes we have indexes. If we have a somewhat fragmented database it can take 45 secondsto get the count. After the reorg/runstats it takes only a second or two. |
#6
| |||
| |||
|
|
Yes we have indexes. *If we have a somewhat fragmented database it can take 45 secondsto get the count. *After the reorg/runstats it takes only a second or two. The reason of getting faster after reorg might be buffer hit ratio |
#7
| |||
| |||
|
|
On 15 Feb, 21:44, shorti <lbrya... (AT) juno (DOT) com> wrote: I am running DB2 V9.5 on AIX. We have a fairly small database (2 million records max on main table). We use COUNT(*) periodically. We also schedule runstats and online reorg periodically. At times COUNT(*) can be very slow and although a reorg/runstats speeds it up we can have a window when the count is needed but reorg/runstats has not yet run. Also, I cannot run reorg/runstats at the time a count is requested since it would take longer to do it than it would be to just wait for the count to return. Any suggestions on what else can be used to get the count of a table? The cardinality isnt accurante until a runstats is done so that is not useful. Is there a quick "rowcount" type way to get this info? I just need a speedy way to get number of records. If you want exact numbers I don't think theres much you can do ( I assume mqt's is out of the question for this ). However, if you accept approximative numbers you can use table samples as in select 100*count(*) from T tablesample system(1) There is also a Bernoulli sample which is more accurate, but slower. See: http://publib.boulder.ibm.com/infoce...74%65%6d%22%20 /Lennart |
#8
| |||
| |||
|
|
Yes we have indexes. If we have a somewhat fragmented database it can take 45 secondsto get the count. After the reorg/runstats it takes only a second or two. I don't think that scanning fragmented table/index take more than 10 times slower than reorged table/index. |
![]() |
| Thread Tools | |
| Display Modes | |
| |