473,802 Members | 2,468 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 39689
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.a c.uk> wrote in message
news:bq******** **@news.ox.ac.u k...
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"."DYN EXPLN" 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.COORDI NATE 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

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

Similar topics

0
5008
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 syntax error back from MySQL. (Refer to ODBC Trace I captured below). metrohouse af8-b94 ENTER SQLExecDirect HSTMT 014D2360 UCHAR * 0x020A0EA2 "select count ( *) from code
2
2246
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 are: *** document document_id (P)
22
12497
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=" & msDbFilename moConn.Properties("Persist Security Info") = False moConn.ConnectionString = msConnString moConn.CursorLocation = adUseClient moConn.Mode = adModeReadWrite' or using default...same result
1
3619
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 "interface" in Access. It's like a little system to make a production plan. It must get information about part numbers, description, set where the part number belongs, quantity of part numbers that the set uses, stock number(this is a text value, it...
3
2513
by: Hasse1982 | last post by:
Hi I have a table KDOCUMENT with the columns , , , , , ,
0
9699
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10535
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10282
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10061
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9111
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4270
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 we have to send another system
3
2966
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.