Speeding query

From: Uros Gruber <uros(at)sir-mag(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Speeding query
Date: 2002-04-24 20:54:52
Message-ID: 57107973818.20020424225452@sir-mag.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi!

I have 2 tables

\d table1

Column | Type
----------------+--------------------------
id_entry | integer
created | timestamp with time zone
title | character varying(64)
description | text

Primary key: table1_pk
Index "table1_pk"
Column | Type
----------+---------
id_entry | integer
unique btree (primary key)

\d table2
Column | Type
-------------+-----------------------
id_category | character varying(64)
id_entry | character varying(64)
Primary key: table2_pk

\d table2_pk
Column | Type
-------------+-----------------------
id_category | character varying(64)
id_entry | character varying(64)
unique btree (primary key)

Not i have query like this

select d.title from table1 d, table2 c where c.id_category='09' and d.id_entry=c.id_entry;

This is query plan

NOTICE: QUERY PLAN:

Nested Loop (cost=0.00..154844.08 rows=96 width=36)
-> Seq Scan on table1 d (cost=0.00..2957.36 rows=25236 width=28)
-> Index Scan using table1_pk on table2 c (cost=0.00..6.00 rows=1 width=8)

I see that there is seq scan over 25k rows, how can i set
indexes to make query faster and use indexes.

--
lp,
Uros mailto:uros(dot)gruber(at)sir-mag(dot)com

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Robert J. Sanford, Jr. 2002-04-24 21:46:19 odd psql behaviour on OSX
Previous Message Uros Gruber 2002-04-24 20:51:25 Help with performance - No2