Re: Deceiding which index to use

From: Richard Huxton <dev(at)archonet(dot)com>
To: Mezei Zoltán <mezei(dot)zoltan(at)telefor(dot)hu>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Deceiding which index to use
Date: 2007-03-09 14:38:22
Message-ID: 45F1715E.1050000@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Mezei Zoltán wrote:
> Hi!
>
> I have two tables with some indices on them:
>
> CREATE TABLE subscriber
> (
> id serial NOT NULL,
> anumber character varying(32) NOT NULL,
> CONSTRAINT subscriber_pk PRIMARY KEY (id)
> )
>
> CREATE INDEX anumber_idx_numeric
> ON subscriber
> USING btree
> (anumber::numeric);

> I would like to run a query like this one:
>
> select l.id
> from output_message_log l join subscriber s on l.subscriber_id = s.id
> where s.anumber::numeric = 5555555555
> order by l.crd desc
> limit 41
> offset 20

Q1. Why are you storing a numeric in a varchar?
Q2. How many unique values does anumber have? And how many rows in
subscriber?
Q3. What happens if you create the index on plain (anumber) and then
test against '555555555'?

--
Richard Huxton
Archonet Ltd

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Mezei Zoltán 2007-03-09 14:53:03 Re: Deceiding which index to use
Previous Message Zoolin Lin 2007-03-09 14:26:43 Re: Any advantage to integer vs stored date w. timestamp