<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Forum PostgreSQL - jak zmienić plan]]></title>
	<link rel="self" href="http://forum.postgresql.org.pl/extern.php?action=feed&amp;tid=594&amp;type=atom"/>
	<updated>2011-05-24T10:50:09Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.postgresql.org.pl/viewtopic.php?id=594</id>
		<entry>
			<title type="html"><![CDATA[Odp: jak zmienić plan]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=2527#p2527"/>
			<content type="html"><![CDATA[Statystyki masz odświeżone?]]></content>
			<author>
				<name><![CDATA[rski]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=26</uri>
			</author>
			<updated>2011-05-24T10:50:09Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=2527#p2527</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[jak zmienić plan]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=2525#p2525"/>
			<content type="html"><![CDATA[pg 8.3

mam sql 

   select *
   from parcels as p 
   join packages pa on pa.package_id = p.package_id 
   join parcel_events e on(p.parcel_id = e.parcel_id)
   join parcel_events_temporary_log l on(e.parcel_event_id = l.parcel_event_id) 
   join event_codes ec on(ec.event_code_id = e.event_code_id) 
   left join users u on(u.user_id = e.user_id) WHERE (u.user_id is not null or e.event_code_id in (459,463)) 
   order by l.sequenced_id ASC 
   limit 10

"Limit  (cost=0.00..876.16 rows=10 width=4114)"
"  ->  Nested Loop  (cost=0.00..32502367.68 rows=370965 width=4114)"
"        ->  Nested Loop  (cost=0.00..28221857.66 rows=370965 width=1928)"
"              ->  Nested Loop Left Join  (cost=0.00..25706655.60 rows=370965 width=765)"
"                    Filter: ((u.user_id IS NOT NULL) OR (e.event_code_id = ANY ('{459,463}'::bigint[])))"
"                    ->  Nested Loop  (cost=0.00..22765473.87 rows=370965 width=680)"
"                          ->  Nested Loop  (cost=0.00..18217473.31 rows=371584 width=146)"
"                                ->  Index Scan using rk_parcel_events_temporary_log on parcel_events_temporary_log l  (cost=0.00..1429239.86 rows=371584 width=21)"
"                                ->  Index Scan using "PK_parcel_events" on parcel_events e  (cost=0.00..45.17 rows=1 width=125)"
"                                      Index Cond: (e.parcel_event_id = l.parcel_event_id)"
"                          ->  Index Scan using "PK_parcels" on parcels p  (cost=0.00..12.23 rows=1 width=534)"
"                                Index Cond: (p.parcel_id = e.parcel_id)"
"                    ->  Index Scan using "PK_users" on users u  (cost=0.00..7.91 rows=1 width=85)"
"                          Index Cond: (u.user_id = e.user_id)"
"              ->  Index Scan using "PK_event_codes" on event_codes ec  (cost=0.00..6.77 rows=1 width=1163)"
"                    Index Cond: (ec.event_code_id = e.event_code_id)"
"        ->  Index Scan using "PK_packages" on packages pa  (cost=0.00..11.53 rows=1 width=2186)"
"              Index Cond: (pa.package_id = p.package_id)"

czy można jakoś zmienic zapytanie żeby było szybciej 

myślałem o czymś takim

select * from 
parcels as p 
   join packages pa on p.package_id = pa.package_id 
   join parcel_events e on(e.parcel_id = p.parcel_id) 
join (
select * from  parcel_events_temporary_log 
where parcel_event_id =e.parcel_event_id
and op_date<'2011-04-01'
order by sequenced_id ASC 
limit 10) as l
   join event_codes ec on(e.event_code_id = ec.event_code_id) 
   left join users u on(e.user_id = u.user_id) 
   WHERE (u.user_id is not null or e.event_code_id in (459,463)) 
   order by l.sequenced_id ASC 

ale ta wersja nie łyka tabeli zewnętrznej w podzapytaniu]]></content>
			<author>
				<name><![CDATA[roku]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1233</uri>
			</author>
			<updated>2011-05-24T10:27:16Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=2525#p2525</id>
		</entry>
</feed>
