473,399 Members | 3,401 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,399 software developers and data experts.

select not using index

2
Hello,

My name is Mihaly Fazekas.
Sorry, my english is not good.

I have a query:
telefon=# EXPLAIN SELECT * FROM ext.ext_unit_hier WHERE now()::date BETWEEN used_from AND used_to;
QUERY PLAN
-------------------------------------------------------------------------
Seq Scan on ext_unit_hier (cost=0.00..242.58 rows=5808 width=36)
Filter: (((now())::date >= used_from) AND ((now())::date <= used_to))
(2 rows)

One of :) index of the table:
"idx_ext_unit_hier_used_from_to" btree (used_from, used_to), tablespace "idx_space"

Number of records in this table at moment: 7343

This table is one element of a "big query".
Wha can i do? (How can SELECT use already presented index?)
Aug 22 '08 #1
2 4137
rski
700 Expert 512MB
i'm not sure if btree works good with multidimensional indexes. maybe try different type of index (rtree or gist)?
Aug 22 '08 #2
vaxx
2
Other version of my problem:
If WHERE contains used_from=now()::date, then query can use index(es).
If WHERE contains "<=" or "<" or ">", then query not use indexes.

I'm checking the multicolumn indexes+btree:
On the postgresql page:
http://www.postgresql.org/docs/8.3/i...lticolumn.html
contains: "Currently, only the B-tree and GiST index types support multicolumn indexes. Up to 32 columns can be specified. "


What can i do?


Indexes:
"idx_ext_unit_hier_used_from" btree (used_from), tablespace "idx_space"
"idx_ext_unit_hier_used_to" btree (used_to), tablespace "idx_space"

telefon=# EXPLAIN SELECT * FROM ext.ext_unit_hier WHERE used_from=now()::date;
QUERY PLAN
-------------------------------------------------------------------------------------------
Bitmap Heap Scan on ext_unit_hier (cost=4.67..66.13 rows=54 width=36)
Recheck Cond: (used_from = (now())::date)
-> Bitmap Index Scan on idx_ext_unit_hier_used_from (cost=0.00..4.66 rows=54 width=0)
Index Cond: (used_from = (now())::date)
(4 rows)

telefon=# EXPLAIN SELECT * FROM ext.ext_unit_hier WHERE used_from<=now()::date;
QUERY PLAN
-------------------------------------------------------------------
Seq Scan on ext_unit_hier (cost=0.00..187.50 rows=7343 width=36)
Filter: (used_from <= (now())::date)
(2 rows)

telefon=# EXPLAIN SELECT * FROM ext.ext_unit_hier WHERE used_from<now()::date;
QUERY PLAN
-------------------------------------------------------------------
Seq Scan on ext_unit_hier (cost=0.00..187.50 rows=7343 width=36)
Filter: (used_from < (now())::date)
(2 rows)
Aug 22 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Denis St-Michel | last post by:
Hello All, Hope some Guru will be able to help me with this. Let's take this example table A ------------------------------------------------------------------------------- id | ...
7
by: Hal Vaughan | last post by:
I have a sample script from a book ("Beginning JavaScript" by Paul Wilton) that removes or adds a choice to a <SELECT> element. The <FORM> is form1 and the <SELECT> is theDay. The example uses...
4
by: psql-mail | last post by:
I am running a SELECT to get all tuples within a given date range. This query is much slwoer than i expected - am i missing something? I have a table 'meta' with a column 'in_date' of type...
2
by: Pavel Stehule | last post by:
Hello, Pg make query 1. and 2. very fast (use index), but for query 3. dont use index. I can solve its using select union, but I readed so pg 7.5 don't problem with OR operator. I use cvs pg. I...
5
by: Silvio Matthes | last post by:
Hello, I'm new to the list and did not find a suitable answer to my question so here it is: I try to select the rows of a table where the content of a varchar-column is empty ('') and...
3
by: Tim Smith | last post by:
I've been benchmarking some very simple databases. By simple, I mean a table like this: CREATE TABLE bench ( id SERIAL, data TEXT ) CREATE INDEX bench_data_index ON bench (data) which is...
29
by: pb648174 | last post by:
I have the following basic statements being executed: Create a temp table, #TempPaging Insert Into #TempPaging (Col1, Col2) Select Col1, Col2 From SomeOtherTable Order By Col2, Col1 Select...
3
by: stefaan.lhermitte | last post by:
Dear MySQL-ians, I perform a SELECT on my database, but it takes over a minute for every run. I have to run it over 10000 times (with different values in the WHERE), so it takes way too long. A...
5
by: Phill W. | last post by:
(VB'2003) What's the correct way to remove multiple, selected items from a ListView control (say, from a ContextMenu)? I ask because I'm getting a very annoying ArgumentOutOfRangeException...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
0
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...
0
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...
0
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,...
0
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...

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.