Re: [GENERAL] INDEX and JOINs

2007-10-27 Thread Reg Me Please
Il Friday 26 October 2007 15:18:04 Tom Lane ha scritto: Reg Me Please [EMAIL PROTECTED] writes: (cost=3.95..382140.91 rows=274709 width=91) (actual time=1.929..57713.305 rows=92 loops=1) Hash Cond: (t_dati.camp_id = t_campi.camp_id) I think the reason it doesn't want to use an indexed

Re: [GENERAL] INDEX and JOINs

2007-10-27 Thread Andreas Kretschmer
Reg Me Please [EMAIL PROTECTED] schrieb: How can I Increasing the statistics target for the larger table? I'ìm sorry for asking, but I'm not that deep into RDBMS. alter table table alter column column SET STATISTICS value; Andreas -- Really, I'm not out to destroy Microsoft. That will just

Re: [GENERAL] INDEX and JOINs

2007-10-27 Thread Reg Me Please
Il Saturday 27 October 2007 08:51:09 Andreas Kretschmer ha scritto: Reg Me Please [EMAIL PROTECTED] schrieb: How can I Increasing the statistics target for the larger table? I'ìm sorry for asking, but I'm not that deep into RDBMS. alter table table alter column column SET STATISTICS value;

Re: [GENERAL] INDEX and JOINs

2007-10-27 Thread Andreas Kretschmer
Reg Me Please [EMAIL PROTECTED] schrieb: Il Saturday 27 October 2007 08:51:09 Andreas Kretschmer ha scritto: Reg Me Please [EMAIL PROTECTED] schrieb: How can I Increasing the statistics target for the larger table? I'ìm sorry for asking, but I'm not that deep into RDBMS. alter table

Re: [GENERAL] INDEX and JOINs

2007-10-26 Thread Martijn van Oosterhout
On Fri, Oct 26, 2007 at 12:34:06PM +0200, Reg Me Please wrote: it's very fast (of course!). But when I run: SELECT * FROM T_DATA NATURAL JOIN T_FIELDS WHERE TABL_ID='TABL'; it's very slow. The EXPLAIN says that in the second case it has to do a sequential scan on T_DATA. And this explains

[GENERAL] INDEX and JOINs

2007-10-26 Thread Reg Me Please
Hi all. I have a setup like this: CREATE TABLE T_FIELDS ( TABL_ID TEXT NOT NULL, COLU_ID TEXT NOT NULL, FIEL_ID TEXT PRIMARY KEY, UNIQUE( TABL_ID,COLU_ID ) ); -- 200 ROWS CREATE TABLE T_DATA ( ITEM_ID INT8 NOT NULL, FIEL_ID TEXT NOT NULL REFERENCES T_FIELDS, DATA_T TEXT NOT NULL,

Re: [GENERAL] INDEX and JOINs

2007-10-26 Thread Reg Me Please
Il Friday 26 October 2007 13:05:10 Martijn van Oosterhout ha scritto: On Fri, Oct 26, 2007 at 12:34:06PM +0200, Reg Me Please wrote: it's very fast (of course!). But when I run: SELECT * FROM T_DATA NATURAL JOIN T_FIELDS WHERE TABL_ID='TABL'; it's very slow. The EXPLAIN says that in

Re: [GENERAL] INDEX and JOINs

2007-10-26 Thread Reg Me Please
Il Friday 26 October 2007 13:56:20 Martijn van Oosterhout ha scritto: On Fri, Oct 26, 2007 at 01:10:42PM +0200, Reg Me Please wrote: prove=# explain analyze SELECT * from t_dati natural left join t_campi where tabe_id='CONTE'; QUERY

Re: [GENERAL] INDEX and JOINs

2007-10-26 Thread Martijn van Oosterhout
On Fri, Oct 26, 2007 at 01:10:42PM +0200, Reg Me Please wrote: prove=# explain analyze SELECT * from t_dati natural left join t_campi where tabe_id='CONTE'; QUERY PLAN

Re: [GENERAL] INDEX and JOINs

2007-10-26 Thread Tom Lane
Reg Me Please [EMAIL PROTECTED] writes: (cost=3.95..382140.91 rows=274709 width=91) (actual time=1.929..57713.305 rows=92 loops=1) Hash Cond: (t_dati.camp_id = t_campi.camp_id) I think the reason it doesn't want to use an indexed join is the large estimate of the number of join result rows.

Re: [GENERAL] INDEX and JOINs

2007-10-26 Thread Martijn van Oosterhout
On Fri, Oct 26, 2007 at 02:39:28PM +0200, Reg Me Please wrote: - Hash Join (cost=3.95..382140.91 rows=274709 width=91) (actual time=1.929..57713.305 rows=92 loops=1) Hash Cond: (t_dati.camp_id = t_campi.camp_id) prove=# \d