473,839 Members | 1,532 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
12 39700
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.a c.uk> a écrit dans le message de
news:bq******** **@news.ox.ac.u k...
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 #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.a c.uk> a ?rit dans le message de
news:bq******** **@news.ox.ac.u k...
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 #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.a c.uk> a écrit dans le message de
news:bq******** **@news.ox.ac.u k...
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.a c.uk> a ?rit dans le message de
news:bq******** **@news.ox.ac.u k...
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 #13

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

Similar topics

0
5010
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
12508
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
3623
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
2515
by: Hasse1982 | last post by:
Hi I have a table KDOCUMENT with the columns , , , , , ,
0
9854
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
9696
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
10903
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...
0
10584
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10645
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
10290
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
9425
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
5681
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4482
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

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.