All pastes #374744 Raw Edit

Someone

public text v1 · immutable
#374744 ·published 2007-02-27 20:18 UTC
rendered paste body
irclogbot=# explain select this_.id as id0_3_, this_.created_at as created2_0_3_, this_.ircuser as ircuser0_3_, this_.body as body0_3_, this_.channel as channel0_3_, user2_.id as id3_0_, user2_.created_at as created2_3_0_, user2_.hostmask as hostmask3_0_, user2_.message_count as message3_3_0_, user2_.name as name3_0_, hostmask3_.id as id2_1_, hostmask3_.created_at as created2_2_1_, hostmask3_.mask as mask2_1_, channel4_.id as id1_2_, channel4_.created_at as created2_1_2_, channel4_.name as name1_2_ from messages this_ left outer join users user2_ on this_.ircuser=user2_.id left outer join hostmasks hostmask3_ on user2_.hostmask=hostmask3_.id left outer join channels channel4_ on this_.channel=channel4_.id order by this_.created_at desc limit 10;
                                                      QUERY PLAN                                                      
----------------------------------------------------------------------------------------------------------------------
 Limit  (cost=196526.89..196526.91 rows=10 width=285)
   ->  Sort  (cost=196526.89..197294.55 rows=307066 width=285)
         Sort Key: this_.created_at
         ->  Hash Left Join  (cost=7272.97..44168.10 rows=307066 width=285)
               Hash Cond: (this_.channel = channel4_.id)
               ->  Hash Left Join  (cost=7258.59..39931.57 rows=307066 width=262)
                     Hash Cond: (this_.ircuser = user2_.id)
                     ->  Seq Scan on messages this_  (cost=0.00..17522.66 rows=307066 width=74)
                     ->  Hash  (cost=5473.96..5473.96 rows=45891 width=188)
                           ->  Hash Left Join  (cost=2142.59..5473.96 rows=45891 width=188)
                                 Hash Cond: (user2_.hostmask = hostmask3_.id)
                                 ->  Seq Scan on users user2_  (cost=0.00..900.91 rows=45891 width=31)
                                 ->  Hash  (cost=759.04..759.04 rows=39004 width=157)
                                       ->  Seq Scan on hostmasks hostmask3_  (cost=0.00..759.04 rows=39004 width=157)
               ->  Hash  (cost=13.61..13.61 rows=61 width=23)
                     ->  Seq Scan on channels channel4_  (cost=0.00..13.61 rows=61 width=23)
(16 rows)

irclogbot=# explain SELECT me.id, me.body, me.created_at, me.channel, me.ircuser, me.vectors, ircuser.id, ircuser.name, ircuser.hostmask, ircuser.created_at, hostmask.id, hostmask.mask, hostmask.created_at, channel.id, channel.name, channel.created_at, channel.network, channel.message_count, network.id, network.address, network.port, network.created_at FROM messages me  JOIN users ircuser ON ( ircuser.id = me.ircuser )  JOIN hostmasks hostmask ON ( hostmask.id = ircuser.hostmask )  JOIN channels channel ON ( channel.id = me.channel )  JOIN networks network ON ( network.id = channel.network ) ORDER BY me.id desc LIMIT 10;
                                                            QUERY PLAN                                                             
-----------------------------------------------------------------------------------------------------------------------------------
 Limit  (cost=1.02..13.40 rows=10 width=528)
   ->  Nested Loop  (cost=1.02..380019.03 rows=307066 width=528)
         ->  Nested Loop  (cost=1.02..280767.20 rows=307066 width=371)
               ->  Nested Loop  (cost=1.02..191278.48 rows=307066 width=344)
                     Join Filter: (network.id = channel.network)
                     ->  Nested Loop  (cost=0.00..177459.49 rows=307066 width=183)
                           ->  Index Scan Backward using messages_pkey on messages me  (cost=0.00..91396.44 rows=307066 width=152)
                           ->  Index Scan using channels_pkey on channels channel  (cost=0.00..0.27 rows=1 width=31)
                                 Index Cond: (channel.id = me.channel)
                     ->  Materialize  (cost=1.02..1.04 rows=2 width=161)
                           ->  Seq Scan on networks network  (cost=0.00..1.02 rows=2 width=161)
               ->  Index Scan using users_pkey on users ircuser  (cost=0.00..0.28 rows=1 width=27)
                     Index Cond: (ircuser.id = me.ircuser)
         ->  Index Scan using hostmasks_pkey on hostmasks hostmask  (cost=0.00..0.31 rows=1 width=157)
               Index Cond: (hostmask.id = ircuser.hostmask)
(15 rows)