473,503 Members | 11,968 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DB2 SELECT COUNT(*) problem

Hi,

Has anyone got problem with this on large table. It seems it take ages to return the result ( half an hour :-( ).

SELECT COUNT(*) FROM COORDINATE

A strange thing is the tempory space (System Managed) keeps growing during the query:

14346747904 Dec 2 16:22 SQL00002.TDA

It's almost as large as the current table (17GB). Any comments?

Many thanks,

Bing

Nov 12 '05 #1
12 39615
Bing Wu wrote:

Hi,

Has anyone got problem with this on large table. It seems it take ages to return the result ( half an hour :-( ).

SELECT COUNT(*) FROM COORDINATE

A strange thing is the tempory space (System Managed) keeps growing during the query:

14346747904 Dec 2 16:22 SQL00002.TDA

It's almost as large as the current table (17GB). Any comments?

Many thanks,

Bing


try:

select count(1) from ...

and see.

hth.
Wolfgang
Nov 12 '05 #2
Many thanks for the hint. It seems still taking long time.

Bing
Wolfgang Riedel wrote:

try:

select count(1) from ...

and see.

hth.
Wolfgang


Nov 12 '05 #3
>Has anyone got problem with this on large table. It seems it take ages to
return the result ( half an hour :-( ).

SELECT COUNT(*) FROM COORDINATE


have you ran explain ? maybe an index would help
Nov 12 '05 #4
Is there any index for the table?
Maybe you should reorg the TS and Indexspace to optimize it.
Form the result count, it's a huge table, if it's not well orgnized, it'll
need a long time to get a result of course.

"Bing Wu" <bi**@biop.ox.ac.uk> wrote in message
news:bq**********@news.ox.ac.uk...
Hi,

Has anyone got problem with this on large table. It seems it take ages to return the result ( half an hour :-( ).
SELECT COUNT(*) FROM COORDINATE

A strange thing is the tempory space (System Managed) keeps growing during the query:
14346747904 Dec 2 16:22 SQL00002.TDA

It's almost as large as the current table (17GB). Any comments?

Many thanks,

Bing

Nov 12 '05 #5
Bing Wu wrote:
Hi,

Has anyone got problem with this on large table. It seems it take ages
to return the result ( half an hour :-( ).

SELECT COUNT(*) FROM COORDINATE

A strange thing is the tempory space (System Managed) keeps growing
during the query:

14346747904 Dec 2 16:22 SQL00002.TDA

It's almost as large as the current table (17GB). Any comments?

Many thanks,

Bing


Are you certain that COORDINATE is a table and not a view? Normally
a simple query like this should not require any temp space. As someone
already mentioned in this thread, get an explain for the query. Once
you do, post it here, maybe someone will be able to help you then.

Regards,
Miro

Nov 12 '05 #6
Yes, it's a table with over a billion rows. I have run the SQL explain and please find the result below.

Thanks again,

Bing
Package Name = "DB2ADMIN"."DYNEXPLN" Version = ""

Prep Date = 2003/12/04
Prep Time = 15:36:33

Bind Timestamp = 2003-12-04-15.36.33.960521

Isolation Level = Cursor Stability
Blocking = Block Unambiguous Cursors
Query Optimization Class = 7

Partition Parallel = No
Intra-Partition Parallel = Yes (Bind Degree = ANY)

SQL Path = "SYSIBM", "SYSFUN", "SYSPROC", "DB2ADMIN"

-------------------- SECTION ---------------------------------------
Section = 1
SQL Statement:
DECLARE C1 CURSOR
FOR
SELECT COUNT(*)
FROM COORDINATE

Intra-Partition Parallelism Degree = 2

Section Code Page = 819

Estimated Cost = 8889258.000000
Estimated Cardinality = 1.000000

Process Using 2 Subagents
| Access Table Name = DB2ADMIN.COORDINATE ID = 4,4
| | #Columns = 0
| | Parallel Scan
| | Relation Scan
| | | Prefetch: Eligible
| | Lock Intents
| | | Table: Intent Share
| | | Row : Next Key Share
| | Sargable Predicate(s)
| | | Partial Predicate Aggregation
| | | | Column Function(s)
| Partial Aggregation Completion
| | Column Function(s)
| Insert Into Asynchronous Local Table Queue ID = q1
Access Local Table Queue ID = q1 #Columns = 1
Final Aggregation
| Column Function(s)
Return Data to Application
| #Columns = 1

End of section
miro flasza wrote:

Are you certain that COORDINATE is a table and not a view? Normally
a simple query like this should not require any temp space. As someone
already mentioned in this thread, get an explain for the query. Once
you do, post it here, maybe someone will be able to help you then.

Regards,
Miro


Nov 12 '05 #7
Yes, it's indexed and organised. I'll try the reorg and see if it improves.

Thanks,

Bing

Jing Li wrote:
Is there any index for the table?
Maybe you should reorg the TS and Indexspace to optimize it.
Form the result count, it's a huge table, if it's not well orgnized, it'll
need a long time to get a result of course.


Nov 12 '05 #8
AK
Bing Wu,

do you have any indexes on the table at all?
Have you run reorgchk?
Nov 12 '05 #9
Likely unrelated, but what happens if you do a select count_big(*)
against the table? Have you done a runstats on the table? Runstats on
its indexes? Can you define a unique index on it (sorry if you'd heard
these sugggestions before)?

Bing Wu wrote:
Yes, it's indexed and organised. I'll try the reorg and see if it improves.

Thanks,

Bing

Jing Li wrote:
Is there any index for the table?
Maybe you should reorg the TS and Indexspace to optimize it.
Form the result count, it's a huge table, if it's not well orgnized,
it'll
need a long time to get a result of course.


Nov 12 '05 #10
Bing, is the access plan with a default query set to 1 the same - relation
scan and not index scan ?

Jean-Marc

"Bing Wu" <bi**@biop.ox.ac.uk> a écrit dans le message de
news:bq**********@news.ox.ac.uk...
Yes, it's a table with over a billion rows. I have run the SQL explain and please find the result below.
Thanks again,

Bing
Package Name = "DB2ADMIN"."DYNEXPLN" Version = ""

Prep Date = 2003/12/04
Prep Time = 15:36:33

Bind Timestamp = 2003-12-04-15.36.33.960521

Isolation Level = Cursor Stability
Blocking = Block Unambiguous Cursors
Query Optimization Class = 7

Partition Parallel = No
Intra-Partition Parallel = Yes (Bind Degree = ANY)

SQL Path = "SYSIBM", "SYSFUN", "SYSPROC", "DB2ADMIN"
-------------------- SECTION ---------------------------------------
Section = 1
SQL Statement:
DECLARE C1 CURSOR
FOR
SELECT COUNT(*)
FROM COORDINATE

Intra-Partition Parallelism Degree = 2

Section Code Page = 819

Estimated Cost = 8889258.000000
Estimated Cardinality = 1.000000

Process Using 2 Subagents
| Access Table Name = DB2ADMIN.COORDINATE ID = 4,4
| | #Columns = 0
| | Parallel Scan
| | Relation Scan
| | | Prefetch: Eligible
| | Lock Intents
| | | Table: Intent Share
| | | Row : Next Key Share
| | Sargable Predicate(s)
| | | Partial Predicate Aggregation
| | | | Column Function(s)
| Partial Aggregation Completion
| | Column Function(s)
| Insert Into Asynchronous Local Table Queue ID = q1
Access Local Table Queue ID = q1 #Columns = 1
Final Aggregation
| Column Function(s)
Return Data to Application
| #Columns = 1

End of section
miro flasza wrote:

Are you certain that COORDINATE is a table and not a view? Normally
a simple query like this should not require any temp space. As someone
already mentioned in this thread, get an explain for the query. Once
you do, post it here, maybe someone will be able to help you then.

Regards,
Miro

Nov 12 '05 #11
Jean-Marc,

Do you mean: SET CURRENT QUERY OPTIMIZATION 1? The current value is 7 at the mo.

Thanks,

Bing

Jean-Marc Blaise wrote:
Bing, is the access plan with a default query set to 1 the same - relation
scan and not index scan ?

Jean-Marc

"Bing Wu" <bi**@biop.ox.ac.uk> a ?rit dans le message de
news:bq**********@news.ox.ac.uk...
Yes, it's a table with over a billion rows. I have run the SQL explain and


please find the result below.
Thanks again,

Bing
Package Name = "DB2ADMIN"."DYNEXPLN" Version = ""

Prep Date = 2003/12/04
Prep Time = 15:36:33

Bind Timestamp = 2003-12-04-15.36.33.960521

Isolation Level = Cursor Stability
Blocking = Block Unambiguous Cursors
Query Optimization Class = 7

Partition Parallel = No
Intra-Partition Parallel = Yes (Bind Degree = ANY)

SQL Path = "SYSIBM", "SYSFUN", "SYSPROC",


"DB2ADMIN"
-------------------- SECTION ---------------------------------------
Section = 1
SQL Statement:
DECLARE C1 CURSOR
FOR
SELECT COUNT(*)
FROM COORDINATE

Intra-Partition Parallelism Degree = 2

Section Code Page = 819

Estimated Cost = 8889258.000000
Estimated Cardinality = 1.000000

Process Using 2 Subagents
| Access Table Name = DB2ADMIN.COORDINATE ID = 4,4
| | #Columns = 0
| | Parallel Scan
| | Relation Scan
| | | Prefetch: Eligible
| | Lock Intents
| | | Table: Intent Share
| | | Row : Next Key Share
| | Sargable Predicate(s)
| | | Partial Predicate Aggregation
| | | | Column Function(s)
| Partial Aggregation Completion
| | Column Function(s)
| Insert Into Asynchronous Local Table Queue ID = q1
Access Local Table Queue ID = q1 #Columns = 1
Final Aggregation
| Column Function(s)
Return Data to Application
| #Columns = 1

End of section
miro flasza wrote:
Are you certain that COORDINATE is a table and not a view? Normally
a simple query like this should not require any temp space. As someone
already mentioned in this thread, get an explain for the query. Once
you do, post it here, maybe someone will be able to help you then.

Regards,
Miro



Nov 12 '05 #12
No, I'm speaking about SET CURRENT DEGREE = '1' , to inhibate the intra
parallelism and see what's the explain gives. You can either set the
max_querydegree parameter in the DB CFG to 1 and change it back, online.

Cheers,

Jean-Marc
"Bing Wu" <bi**@biop.ox.ac.uk> a écrit dans le message de
news:bq**********@news.ox.ac.uk...
Jean-Marc,

Do you mean: SET CURRENT QUERY OPTIMIZATION 1? The current value is 7 at the mo.
Thanks,

Bing

Jean-Marc Blaise wrote:
Bing, is the access plan with a default query set to 1 the same - relation scan and not index scan ?

Jean-Marc

"Bing Wu" <bi**@biop.ox.ac.uk> a ?rit dans le message de
news:bq**********@news.ox.ac.uk...
Yes, it's a table with over a billion rows. I have run the SQL explain
and
please find the result below.
Thanks again,

Bing
Package Name = "DB2ADMIN"."DYNEXPLN" Version = ""

Prep Date = 2003/12/04
Prep Time = 15:36:33

Bind Timestamp = 2003-12-04-15.36.33.960521

Isolation Level = Cursor Stability
Blocking = Block Unambiguous Cursors
Query Optimization Class = 7

Partition Parallel = No
Intra-Partition Parallel = Yes (Bind Degree = ANY)

SQL Path = "SYSIBM", "SYSFUN", "SYSPROC",


"DB2ADMIN"
-------------------- SECTION ---------------------------------------
Section = 1
SQL Statement:
DECLARE C1 CURSOR
FOR
SELECT COUNT(*)
FROM COORDINATE

Intra-Partition Parallelism Degree = 2

Section Code Page = 819

Estimated Cost = 8889258.000000
Estimated Cardinality = 1.000000

Process Using 2 Subagents
| Access Table Name = DB2ADMIN.COORDINATE ID = 4,4
| | #Columns = 0
| | Parallel Scan
| | Relation Scan
| | | Prefetch: Eligible
| | Lock Intents
| | | Table: Intent Share
| | | Row : Next Key Share
| | Sargable Predicate(s)
| | | Partial Predicate Aggregation
| | | | Column Function(s)
| Partial Aggregation Completion
| | Column Function(s)
| Insert Into Asynchronous Local Table Queue ID = q1
Access Local Table Queue ID = q1 #Columns = 1
Final Aggregation
| Column Function(s)
Return Data to Application
| #Columns = 1

End of section
miro flasza wrote:

Are you certain that COORDINATE is a table and not a view? Normally
a simple query like this should not require any temp space. As someone
already mentioned in this thread, get an explain for the query. Once
you do, post it here, maybe someone will be able to help you then.

Regards,
Miro


Nov 12 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
4980
by: Fatt Shin | last post by:
Hi, I'm running MySQL 4.0.13, connecting from PowerBuilder 9 using ODCB Connector 3.51. I'm facing a problem where whenever I issue a SELECT COUNT(*) statement from PowerBuilder, I always get SQL...
2
2231
by: TGOS | last post by:
Here's a little question to MySQL Gurus. Two tables. One called 'document' one called 'page'. Needles to say, a document consist out of multiple pages (1:n). The primary (P) and foreign (F) keys...
22
12424
by: MP | last post by:
vb6,ado,mdb,win2k i pass the sql string to the .Execute method on the open connection to Table_Name(const) db table fwiw (the connection opened via class wrapper:) msConnString = "Data Source="...
1
3606
by: zafm86 | last post by:
Hi everyone! I'm sure my problem is pretty easy to solve but I've been working on it for a long and my my brain is not working correctly anymore. I'm working with an AS400 and I mhave to do an...
3
2498
by: Hasse1982 | last post by:
Hi I have a table KDOCUMENT with the columns , , , , , ,
0
7212
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7364
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7470
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4696
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1524
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
751
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.