473,386 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

extract epoch and index scanning

Can someone explain why the latter query uses an index scan while the
former uses a sequence scan? I have tried all sorts of casting in the
first case but I cannot get the index scan.

Cheers,
Randall

==
data=> EXPLAIN ANALYZE SELECT acqtimestamp FROM aux_datarecord where
acqtimestamp between (extract(epoch from timestamp '2004-02-21
22:39:57+00') - 50716800)::double precision and (extract(epoch from
timestamp '2004-02-21 22:43:52+00'::timestamp) - 50716800.0)::double
precision;
NOTICE:
QUERY PLAN:

Seq Scan on aux_datarecord (cost=100000000.00..100548707.00
rows=477476 width=8) (actual time=114670.09..114670.09 rows=0 loops=1)
Total runtime: 114670.23 msec

EXPLAIN

data=> EXPLAIN ANALYZE SELECT acqtimestamp FROM aux_datarecord where
acqtimestamp between '1026686397'::double precision and
'1026686632'::double precision;
NOTICE:
QUERY PLAN:

Index Scan using aux_datarecord_acqtimestamp on aux_datarecord
(cost=0.00..3.54 rows=1 width=8) (actual time=0.66..0.66 rows=0
loops=1)
Total runtime: 0.83 msec

EXPLAIN
==
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 23 '05 #1
1 2186
This seems to be peculuar to our operational database which is version
7.2.x. Version 7.4 gives the index scan.

Cheers,
Randall

On 8 Apr 2004, at 14:28, Randall Skelton wrote:
Can someone explain why the latter query uses an index scan while the
former uses a sequence scan? I have tried all sorts of casting in the
first case but I cannot get the index scan.

Cheers,
Randall

==
data=> EXPLAIN ANALYZE SELECT acqtimestamp FROM aux_datarecord where
acqtimestamp between (extract(epoch from timestamp '2004-02-21
22:39:57+00') - 50716800)::double precision and (extract(epoch from
timestamp '2004-02-21 22:43:52+00'::timestamp) - 50716800.0)::double
precision;
NOTICE:
QUERY PLAN:

Seq Scan on aux_datarecord (cost=100000000.00..100548707.00
rows=477476 width=8) (actual time=114670.09..114670.09 rows=0 loops=1)
Total runtime: 114670.23 msec

EXPLAIN

data=> EXPLAIN ANALYZE SELECT acqtimestamp FROM aux_datarecord where
acqtimestamp between '1026686397'::double precision and
'1026686632'::double precision;
NOTICE:
QUERY PLAN:

Index Scan using aux_datarecord_acqtimestamp on aux_datarecord
(cost=0.00..3.54 rows=1 width=8) (actual time=0.66..0.66 rows=0
loops=1)
Total runtime: 0.83 msec

EXPLAIN
==
---------------------------(end of
broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 23 '05 #2

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

Similar topics

2
by: Jason | last post by:
I have a primary key that comprises 2 columns (lets say ReportDate and Symbol). I know that if I submit a statement like SELECT * FROM T1 WHERE ReportDate = '20031219' AND Symbol = 'XYZ' it will...
25
by: sql_server_2000_user | last post by:
Hi, I have a table with about 305 million rows, and a composite primary key that consists of an ascending int and an ascending varchar(18), which is typically of length 13. Even if all the keys...
2
by: Darren Ferguson | last post by:
Hey all I am trying to extract the epoch from a timestamp variable in plpgsql. The function is as follows: create or replace function test() returns integer as ' declare _test timestamp with...
17
by: Jeffrey W. Baker | last post by:
Greetings, I have a 23GB data table upon which I am building a primary key of three columns. The data is mounted in a 137GB device and pg_xlog is mounted on a separate 3.5GB device. I have...
2
by: Stefan Antonelli | last post by:
Hi, i have to convert several timestamps. The given format, eg "yyyy-mm-dd hh:mm:ss" has to be converted to an epoch string. Is there any proper way to do this? If not, i have to split the...
3
by: Mark | last post by:
I want to simply get the unix style epoch time (number of secs to now from Jan 01, 1970 UTC) for use as a timestamp to track the staleness of some objects. So I don't care about time zones or...
5
by: Grey Alien | last post by:
I need to convert timestamps that are given as the number of seconds that have elapsed since midnight UTC of January 1, 1970, (not counting leap seconds). It seems all of the std C functions...
11
by: usenet | last post by:
Is the epoch time the number of seconds elapsed since January 1st 1970 in my timezone or as per UTC? I mean, if A's program makes a call to time() in Melboune and B's program makes a call to...
2
by: Richard Rossel | last post by:
Hi friends, I need a little help here, I 'm stuck with epoch calculation issue. I have this datetime: date_new = datetime(*time.strptime('20080101T000000','%Y%m%dT%H%M%S') ) This date_new is in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
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...

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.