Re: [GENERAL] funny view/temp table problem with query

2009-02-27 Thread Grzegorz Jaśkiewicz
On Fri, Feb 27, 2009 at 11:57 AM, Gregory Stark wrote: > Uh, we get a lot of really mangled SQL and explain plans -- I don't see > anything wrong with these. If the question was unclear it sounds like it's > just because it's a fairly subtle problem and was hard to describe. Needing > two cracks

Re: [GENERAL] funny view/temp table problem with query

2009-02-27 Thread Gregory Stark
Alban Hertroys writes: > On Feb 26, 2009, at 11:02 AM, Grzegorz Jaśkiewicz wrote: > >> looks like you completely misunderstood my question. > > I'm not surprised. What do you expect with random capitalisation, random > table > alias names and random indentation combined with queries getting wr

Re: [GENERAL] funny view/temp table problem with query

2009-02-27 Thread Scott Marlowe
On Fri, Feb 27, 2009 at 3:16 AM, Grzegorz Jaśkiewicz wrote: > 2009/2/27 Scott Marlowe : >> Nope. > > as far as I can understand it, if I do the same thing in two steps, > and in one step. And the latter is broken, because of some internal > process/optimization/whatever - that's a bug to me. You'

Re: [GENERAL] funny view/temp table problem with query

2009-02-27 Thread Grzegorz Jaśkiewicz
2009/2/27 Scott Marlowe : > Nope. as far as I can understand it, if I do the same thing in two steps, and in one step. And the latter is broken, because of some internal process/optimization/whatever - that's a bug to me. Unless I am expecting it to work, and it was just pure luck that it worked

Re: [GENERAL] funny view/temp table problem with query

2009-02-27 Thread Scott Marlowe
On Fri, Feb 27, 2009 at 3:10 AM, Grzegorz Jaśkiewicz wrote: > 2009/2/27 Scott Marlowe : >> On Thu, Feb 26, 2009 at 3:02 AM, Grzegorz Jaśkiewicz >> wrote: >> >>> First of all, I wonder why the same query divided up in half - and >>> using temporary table works as expected, and with everything tog

Re: [GENERAL] funny view/temp table problem with query

2009-02-27 Thread Grzegorz Jaśkiewicz
2009/2/27 Scott Marlowe : > On Thu, Feb 26, 2009 at 3:02 AM, Grzegorz Jaśkiewicz > wrote: > >> First of all, I wonder why the same query divided up in half - and >> using temporary table works as expected, and with everything together > > I'm betting it's your use of generate_series().  You can g

Re: [GENERAL] funny view/temp table problem with query

2009-02-26 Thread Scott Marlowe
On Thu, Feb 26, 2009 at 3:02 AM, Grzegorz Jaśkiewicz wrote: > First of all, I wonder why the same query divided up in half - and > using temporary table works as expected, and with everything together I'm betting it's your use of generate_series(). You can get some weird side effects because it

Re: [GENERAL] funny view/temp table problem with query

2009-02-26 Thread Joshua D. Drake
On Fri, 2009-02-27 at 01:36 +0100, Alban Hertroys wrote: > On Feb 26, 2009, at 11:02 AM, Grzegorz Jaśkiewicz wrote: > You're the one who's asking a question, it's your responsibility that > we can understand your problem. Woah... ease up cowboy. Joshua D. Drake -- PostgreSQL - XMPP: jdr...

Re: [GENERAL] funny view/temp table problem with query

2009-02-26 Thread Alban Hertroys
On Feb 26, 2009, at 11:02 AM, Grzegorz Jaśkiewicz wrote: looks like you completely misunderstood my question. I'm not surprised. What do you expect with random capitalisation, random table alias names and random indentation combined with queries getting wrapped by the mailing-list software

Re: [GENERAL] funny view/temp table problem with query

2009-02-26 Thread Grzegorz Jaśkiewicz
looks like you completely misunderstood my question. First of all, I wonder why the same query divided up in half - and using temporary table works as expected, and with everything together doesn't. And about rand(), it was tested on large enough set of runs, that I don't think it is to blame. The

Re: [GENERAL] funny view/temp table problem with query

2009-02-26 Thread Alban Hertroys
On Feb 25, 2009, at 11:02 AM, Grzegorz Jaśkiewicz wrote: So I have a 'accounts' table, with id and name, and than some hypothetical 'packages' table, containing some info per customer. I need to retrive distinct pairs , of random packages assigned per customer. Packages table contains 10 pac

Re: [GENERAL] funny view/temp table problem with query

2009-02-25 Thread Grzegorz Jaśkiewicz
all explains: Query without view: QUERY PLAN Aggregate (cost=94419553.37..94419553.38 rows=1 width=16) -> Sort (cost=94269553.37..

[GENERAL] funny view/temp table problem with query

2009-02-25 Thread Grzegorz Jaśkiewicz
So I have a 'accounts' table, with id and name, and than some hypothetical 'packages' table, containing some info per customer. I need to retrive distinct pairs , of random packages assigned per customer. Packages table contains 10 packages, id:=[1:10], there's 1M customers for testing purposes.