Re: [PERFORM] weird query plan

2007-06-06 Thread Tom Lane
weiping <[EMAIL PROTECTED]> writes: > -> Index Scan using urlusermaps_userid on wd_urlusermaps a > (cost=0.00..6750.55 rows=1094 width=96) (actual time=0.544..5.616 > rows=41 loops=1) > Index Cond: (userid = 219177) > Filter: ("share" = 1) > the userid=219177 got 2000+ record and around 40 shared=

Re: different query plan because different limit # (Re: [PERFORM] weird query plan)

2007-06-06 Thread Gregory Stark
"weiping" <[EMAIL PROTECTED]> writes: > -> Index Scan using urlusermaps_userid on wd_urlusermaps >(cost=0.00..6750.55 rows=1094 width=4) (actual time=1.478..16.563 rows=41 > loops=1) >Index Cond: (userid = 219177) >Filter: ("share" = 1) It's estimating 1094 rows and getting 41 rows.

Re: different query plan because different limit # (Re: [PERFORM] weird query plan)

2007-06-06 Thread weiping
continue digging shows: set cpu_tuple_cost to 0.1; explain analyze select * from wd_urlusermaps where share =1 and userid='219177' order by id desc limit 20; SET 时间: 0.256 ms QUERY PLAN -

different query plan because different limit # (Re: [PERFORM] weird query plan)

2007-06-06 Thread weiping
I changed the query to : EXPLAIN ANALYZE select id from wd_urlusermaps where id in (select id from wd_urlusermaps where share =1 and userid='219177') order by id desc limit 20; and it's much better now (from real execute time), but the cost report higher then slower one above, may be I should do s

Re: [PERFORM] weird query plan

2007-06-05 Thread weiping
sorry, forgot to mention our version, it's postgresql 8.2.3 -laser > I have a table: > webdigest=# \d wd_urlusermaps > 表 "public.wd_urlusermaps" > 字段名 | 类型 | 修饰词 > -+-+- > id | integer | not null defaul

[PERFORM] weird query plan

2007-06-05 Thread weiping
I have a table: webdigest=# \d wd_urlusermaps 表 "public.wd_urlusermaps" 字段名 | 类型 | 修饰词 -+-+- id | integer | not null default nextval('wd_urlusermaps_id_seq'::regclass) urlid | integer | not null tag | ch