pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Roman Fail <rfail@posportal.com>
To: Jeff <threshar@torgo.978.org>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Josh Berkus <josh@agliodbs.com>
Cc: sszabo@megazone23.bigpanda.com
Cc: pgsql-performance@postgresql.org
Subject: Implicit casting and JOIN syntax constraints
Date: Fri, 17 Jan 2003 06:48:28 -0800
Message-ID: <9B1C77393DED0D4B9DAA1AA1742942DA0E4C0B@pos_pdc.posportal.com> (raw)

>> HOWEVER.....look at this:
>> EXPLAIN ANALYZE select batchdetailid from batchdetail where batchdetailid = 27321::bigint;
>>  Index Scan using batchdetail_pkey on batchdetail  (cost=0.00..4.13 rows=1 width=8) (actual time=0.03..0.03 rows=1 loops=1)
>>    Index Cond: (batchdetailid = 27321::bigint)
>>  Total runtime: 0.07 msec

> Jeff Trout wrote:
> We had this happen to us - we had a serial8 column (int8) and our query
> was straight forward where id = 12345; which ran craptacularly.  After
> much head banging and cursing I had tried where id = '12345' and it
> magically worked. I think the parser is interpreting a "number" to be an
> int4 instead of int8.  (instead of quotes you can also cast via
> 12345::int8 like you did)

> Perhaps this should go on the TODO - when one side is an int8 and the
> other is a literal number assume the number to be int8 instead of int4?

It seems to me that this should absolutely go on the TODO list.  Why does the planner require an explicit cast when the implicit cast is so obvious?  Does Oracle do this?  I can assure you that MSSQL does not.  
 
If getting more people to migrate to PostgreSQL is a major goal these days, it's got to be relatively easy.  I think that almost everyone coming from a MSSQL or Access background is going to have big problems with this.  And the other issue of the JOIN syntax constraining the planner - you've got to be able to turn that off too.  I've been writing SQL queries for 10 years in FoxPro, Access, SQL Server, MySQL, and Sybase.  I have never come across this very confusing "feature" until now.  
 
How do we go about voting an issue onto the TODO list?  These two get my vote for sure!
 
Roman


view thread (2+ messages)  latest in thread

Message-ID: <9B1C77393DED0D4B9DAA1AA1742942DA0E4C0B@pos_pdc.posportal.com>
Permalink:  ../9B1C77393DED0D4B9DAA1AA1742942DA0E4C0B@pos_pdc.posportal.com/
Also on:    postgresql.org/message-id/9B1C77393DED0D4B9DAA1AA1742942DA0E4C0B@pos_pdc.posportal.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: rfail@posportal.com, threshar@torgo.978.org, tgl@sss.pgh.pa.us, josh@agliodbs.com, sszabo@megazone23.bigpanda.com
  Subject: Re: Implicit casting and JOIN syntax constraints
  In-Reply-To: <9B1C77393DED0D4B9DAA1AA1742942DA0E4C0B@pos_pdc.posportal.com>
  References: <9B1C77393DED0D4B9DAA1AA1742942DA0E4C0B@pos_pdc.posportal.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox