<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Forum PostgreSQL - jak zmienić plan]]></title>
		<link>https://forum.postgresql.org.pl/viewtopic.php?id=594</link>
		<description><![CDATA[Najświeższe odpowiedzi w jak zmienić plan.]]></description>
		<lastBuildDate>Tue, 24 May 2011 10:50:09 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Odp: jak zmienić plan]]></title>
			<link>https://forum.postgresql.org.pl/viewtopic.php?pid=2527#p2527</link>
			<description><![CDATA[Statystyki masz odświeżone?]]></description>
			<author><![CDATA[dummy@example.com (rski)]]></author>
			<pubDate>Tue, 24 May 2011 10:50:09 +0000</pubDate>
			<guid>https://forum.postgresql.org.pl/viewtopic.php?pid=2527#p2527</guid>
		</item>
		<item>
			<title><![CDATA[jak zmienić plan]]></title>
			<link>https://forum.postgresql.org.pl/viewtopic.php?pid=2525#p2525</link>
			<description><![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]]></description>
			<author><![CDATA[dummy@example.com (roku)]]></author>
			<pubDate>Tue, 24 May 2011 10:27:16 +0000</pubDate>
			<guid>https://forum.postgresql.org.pl/viewtopic.php?pid=2525#p2525</guid>
		</item>
	</channel>
</rss>
