Re: PostgreSQL Indexing versus MySQL

From: Jan Wieck <JanWieck(at)Yahoo(dot)com>
To: Lincoln Yeoh <lyeoh(at)pop(dot)jaring(dot)my>
Cc: "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com>, Chris Fossenier <chris(at)engenuit(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: PostgreSQL Indexing versus MySQL
Date: 2004-02-18 13:25:42
Message-ID: 403367D6.1000408@Yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Lincoln Yeoh wrote:
> At 04:14 PM 2/17/2004 -0700, scott.marlowe wrote:
>>custom type (hex, foobar, etc...) from one to another. What this means
>>too you, the user, is that:
>>
>>create table test (id int8, info text);
>><insert 10,000 rows>
>>select * from test where id=456;
>>
>>will result in a sequential scan. Why? Because the default integer type
>>is int4, and your id field is int8. Cast the value to int8, and watch it
>>use an index scan:
>>
>>select * From test where id=cast(456 as int8);
>
> Actually won't
> select * from test where id='456'
> use the index?
>
> I'm curious if this work in all cases - e.g. postgresql figures the best
> cast for text to whatever, even for relevant custom types?
>

'456' is not text, it is a quoted literal of (yet) unknown type and kept
that way for long enough to know that it should be an int8, ideally.

Jan

--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck(at)Yahoo(dot)com #

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jan Poslusny 2004-02-18 13:33:43 Re: Numbering a records
Previous Message NTPT 2004-02-18 12:56:06 Numbering a records