[NOVICE] Re: Queries with Joins before filtering taking too much time! Filter(where clause) *first* -- suggestions ? - Mailing list pgsql-novice

From Hursh Jain
Subject [NOVICE] Re: Queries with Joins before filtering taking too much time! Filter(where clause) *first* -- suggestions ?
Date
Msg-id 587C19D7.5080008@gmail.com
Whole thread Raw
In response to [NOVICE] Queries with Joins before filtering taking too much time! Filter(where clause) *first* -- suggestions ?  (Hursh Jain <hurshj@gmail.com>)
Responses Re: [NOVICE] Queries with Joins before filtering taking too muchtime! Filter (where clause) *first* -- suggestions ?  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-novice
As a followup:

I noticed that there isn't any "pid" column in the reward table. So that
was an error and maybe that's why a sequential scan was being forced. To
recap, the query was:

SELECT
  *
FROM
property p
LEFT OUTER JOIN users ON (p.current_owner = users.uid)
WHERE
p.pid in
(SELECT pid FROM reward WHERE reward_type = 'daily'
ORDER BY reward_date DESC LIMIT 30)

But weirdly, the query still runs without any errors. Why ?

===

I tried this (a simpler version of the above):

SELECT * from property
WHERE pid in (
   SELECT pid FROM reward WHERE reward_type = 'DAILYPROMO_WIN')
;

And this also runs (again taking a long time) but without any errors.
How can this be ? (there is no pid in the reward table, so why does the
subquery not throw an error)? In fact, because there was no error, I
didn't notice my typo (no pid in reward table) until right now...

Best,
--J


pgsql-novice by date:

Previous
From: Hursh Jain
Date:
Subject: [NOVICE] Queries with Joins before filtering taking too much time! Filter(where clause) *first* -- suggestions ?
Next
From: "David G. Johnston"
Date:
Subject: Re: [NOVICE] Queries with Joins before filtering taking too muchtime! Filter (where clause) *first* -- suggestions ?