473,804 Members | 3,716 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Date column and table scan

Hi,

DB2 7 FP 13
Windows XP

I have a table in which on of the columns has the data type DATE. The date
column is indexed (asc non-unique index). Every SQL I create which tries to
filter by this date column produces a table scan, even a simple

select DATECOL from MYTABLE where DATECOL=date('2 004-09-16')

Does searching by dates in general produce a table scan?
Does it make sense to index a date column?
How should one best index a column of type date, if at all necessary?

Note: runstats were performed on the table. There are only 30000 rows in the
table of which 10 match the where clause.

Regards

Rudolf Bargholz
Nov 12 '05 #1
5 3473
have you run reorgchk against MYTABLE recently?
did you run RUNSTATS ON TABLE xxxx WITH DISTRIBUTION AND DETAILED
INDEXES ALL?

Nov 12 '05 #2
have you run reorgchk against MYTABLE recently?
did you run RUNSTATS ON TABLE xxxx WITH DISTRIBUTION AND DETAILED
INDEXES ALL?

Nov 12 '05 #3
Hi Ak,

<ak************ @yahoo.com> schrieb im Newsbeitrag
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
have you run reorgchk against MYTABLE recently?
did you run RUNSTATS ON TABLE xxxx WITH DISTRIBUTION AND DETAILED
INDEXES ALL?


Yes, I ran both, first the reorg, then the runstats.

What I have found in the mean time is, if I allow reverse scans on the date
columns, only then is an index scan and not a table scan used. Have changed
our database table/index synchronizer appropriately.

Regards

Rudolf Bargholz
Nov 12 '05 #4
Rudolf,
it is very interesting. Which optimization level are you using?
What if you create a table ONE_DATE(ONE_VA LUE DATE), enter the value
and try
select DATECOL from MYTABLE
JOIN ONE_DATE ON MYTABLE.DATECOL = ONE_DATE.ONE_VA LUE

Nov 12 '05 #5
Rudolf,
it is very interesting. Which optimization level are you using?
What if you create a table ONE_DATE(ONE_VA LUE DATE), enter the value
and try
select DATECOL from MYTABLE
JOIN ONE_DATE ON MYTABLE.DATECOL = ONE_DATE.ONE_VA LUE

Nov 12 '05 #6

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

Similar topics

4
15544
by: ryan | last post by:
Hi Everyone, I'm having trouble convincing myself that Oracle is executing a query of mine as efficiently as possible, and I'm looking for a little guidance. The situation is pretty simple. I just have two tables, PARENT and CHILD. PARENT( pkey int primary key,
3
5901
by: Marcus | last post by:
Hi I have a very complex sql query and a explain plan. I found there is a full table scan in ID=9 9 8 TABLE ACCESS (FULL) OF 'F_LOTTXNHIST' (Cost=84573 Card=185892 Bytes=7063896) How can I correlate which part of the SQL statement is running on full table scan. Please see below for the code and explain plan SQL Code
4
7218
by: John Siracusa | last post by:
How can I create a non-null date column that defaults to 'now' as computed at the time the row is inserted? -John ---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to majordomo@postgresql.org so that your message can get through to the mailing list cleanly
6
5743
by: robert | last post by:
just got out of a "class" on EXPLAIN, from a 390/v6 maven. was told that ACCESSTYPE = 'R' in the plan_table meant a TableSpace scan. hmmmm. next step up (or down, depending on your outlook) wasn't a Table Scan. thought this might be a MainFrame thing; but a look at DB2Info on my UDB 7.2 server showed the same thing. this is truly puzzling. is there an explanation of EXPLAIN which describes how to get a Table Scan???? or are we...
3
2784
by: selma | last post by:
I am puzzled by visual explain for a simple query ( select * from mytable ) chooses an index scan. That index has only a single column and the table has 30 columns not covered by the index. When running explain for another database (same schema structure), it showed table scan. These are all production databases with >10 GB of real data, and stats are all up to date. Reorgchk showed nothing bad. Per chance visual explain GUI was acting...
10
2432
by: Dia | last post by:
At the company I work job applicants are required to do a little test. The human resource manager recently had a candidate who claimed one of the questions was ambiguous. Dependent upon the version of DB2 one or the other answer of a multiple choice question could be right, the candidate said. The HRM asked me to look into the matter, but since I am no expert in the workings of DB2 I submit the question to you hoping any of you can
2
6384
by: db2udbgirl | last post by:
If I perform a select count(*) from tred.order_delivery query will it internally perform a full table scan to determine the row count for the following scenario case 1: There is a primary key on a column case 2: There is a compound key on 1 columns col1, col2 case 3: No primary key in the table (Just for my education)
8
3072
by: Michel Esber | last post by:
Hello, DB2 V8 FP 11 running on Linux. Given two tables: T_SW_ID (SW_ID INTEGER, SW_NAME VARCHAR); T_SW (MACHINE_ID varchar, SW_ID DECIMAL (8), VERSION varchar, Product_ID varchar)
2
2501
by: BD | last post by:
Hi, all. My background is more Oracle than db2. My skills at SQL tuning are quite limited. I'm running 8.2 on Windows. I'm tasked with some SQL optimization, and am doing some explain plans on various queries.
0
9707
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
9585
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
10338
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...
0
10082
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
6856
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5525
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
4301
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
2
3823
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2997
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.