Re: [PERFORM] Optimizing a query

2013-12-23 Thread Mark Kirkwood
On 20/12/13 06:53, Shaun Thomas wrote: On 12/17/2013 08:48 PM, Kai Sellgren wrote: This is your select: SELECT * FROM "Log" LEFT JOIN "NewsArticle" ON "NewsArticle".id = "Log"."targetId" AND "Log"."targetType" = 'NewsArticle' ORDER BY "Log"."createdAt" DESC LIMIT 10 This is your index: CRE

Re: [PERFORM] Optimizing a query

2013-12-19 Thread Shaun Thomas
On 12/17/2013 08:48 PM, Kai Sellgren wrote: This is your select: SELECT * FROM "Log" LEFT JOIN "NewsArticle" ON "NewsArticle".id = "Log"."targetId" AND "Log"."targetType" = 'NewsArticle' ORDER BY "Log"."createdAt" DESC LIMIT 10 This is your index: CREATE INDEX "Log_targetId_targetType_idx"

[PERFORM] Optimizing a query

2013-12-19 Thread Kai Sellgren
Hi, I'm new to PostgreSQL and trying to run this query: SELECT * FROM "Log" LEFT JOIN "NewsArticle" ON "NewsArticle".id = "Log"."targetId" AND "Log"."targetType" = 'NewsArticle' ORDER BY "Log"."createdAt" DESC LIMIT 10 Basically I'm finding the last 10 log entries, which point (targetType) to ne

Re: [PERFORM] Optimizing a query

2006-12-13 Thread Tomeh, Husam
esql.org Subject: Re: [PERFORM] Optimizing a query >>>>> "Husam" == Tomeh, Husam <[EMAIL PROTECTED]> writes: Husam> Have you run vacuum/analyze on the table? Yes, back when I first noticed how slow it was. It did not make any difference. explain analyze says: , | n=

Re: [PERFORM] Optimizing a query

2006-12-13 Thread James Cloos
> "Husam" == Tomeh, Husam <[EMAIL PROTECTED]> writes: Husam> Have you run vacuum/analyze on the table? Yes, back when I first noticed how slow it was. It did not make any difference. explain analyze says: , | n=# explain analyse select * from nanpa where npa=775 and nxx=473; |

Re: [PERFORM] Optimizing a query

2006-12-13 Thread Tom Lane
James Cloos <[EMAIL PROTECTED]> writes: > ... and was doing queries of the form: > | select * from nanpa where npa=775 and nxx=413; If those are char(3) columns, shouldn't you be quoting the constants? select * from nanpa where npa='775' and nxx='413'; Any non-numeric input will fail entirely wi

Re: [PERFORM] Optimizing a query

2006-12-13 Thread Tomeh, Husam
Have you run vacuum/analyze on the table? -- Husam -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of James Cloos Sent: Wednesday, December 13, 2006 10:48 AM To: pgsql-performance@postgresql.org Subject: [PERFORM] Optimizing a query I've currentl

[PERFORM] Optimizing a query

2006-12-13 Thread James Cloos
I've currently got this table: , | n=# \d nanpa | Table "public.nanpa" |Column | Type | Modifiers | +--+--- | state | character(2) | | npa| character(3) | not null | nxx| character(3) | not null | ocn| ch