updates.time = '2017-12-30 15:57:35.267405'::timestamp without time zone) AND (updates.originating_update_id <= 10000000)))
         Heap Fetches: 0
         Buffers: shared hit=1856
 Planning time: 0.202 ms
 Execution time: 35.493 ms
(11 rows)

and without
 Limit  (cost=0.69..0.78 rows=1 width=39) (actual time=0.045..0.045 rows=1 loops=1)
   Output: time, update_id, amount, eid, originating_update_id
   Buffers: shared hit=6
   ->  Index Only Scan using updates_covering_idx3 on public.updates  (cost=0.69..762.10 rows=8383 width=39) (actual time=0.044..0.044 rows=1 loops=1)
         Output: time, update_id, amount, eid, originating_update_id
         Index Cond: ((updates.account_id = '1'::text) AND (updates.attr1 = ''::text) AND (updates.attr2 = 3) AND (updates.attr3 = 'ABC'::text) AND (updates.time <= '2017-12-30 15:57:35.267405'::timestamp without time zone))
         Filter: ((updates.time < '2017-12-30 15:57:35.267405'::timestamp without time zone) OR ((updates.time = '2017-12-30 15:57:35.267405'::timestamp without time zone) AND (updates.originating_update_id <= 10000000)))
         Heap Fetches: 0
         Buffers: shared hit=6
 Planning time: 0.201 ms
 Execution time: 0.073 ms
(11 rows)

A:

This kind of makes sense if your data are distributed in certain way. Without the update_id < 40581 condition the very first entry in the index that matches account_id = '1' AND attr1 = '' AND attr2 = 3 AND attr3 = 'ABC' satisfies the LIMIT clause, because the entries are ordered appropriately. With the condition in place it has to go and
updates.time =' 2017 - 12 - 30 15:57:35.267405'::timestamp without time zone) AND (updates.originating_update_id < = 10000000) )) 
          Heap Fetches: 0 
          Buffers: shared hit=1856 
  Planning time: 0.202 ms 
  Execution meter: 35.493 ms 
 (11 row) 

 and without 
  Limit   (cost=0.69.. 0.78 rows=1 width=39) (actual time=0.045.. 0.045 rows=1 loops=1) 
    Output: time, update_id, amount, eid, originating_update_id 
    buffer zone: shared hit=6 
    - >   Index Only Scan use updates_covering_idx3 on public.updates   (cost=0.69.. 762.10 rows=8383 width=39) (actual time=0.044.. 0.044 rows=1 loops=1) 
          output signal: time, update_id, sum, eid, originating_update_id 
          Index Cond: (( updates.account_id =' 1'::text) AND (updates.attr1 =": : text) AND (updates.attr2 = 3) AND (updates.attr3 =' ABC'::text) AND (updates.time < =' 2017 - 12 - 30 15:57:35.267405'::timestamp without time zone) ) 
          Filter: (( updates.time <' 2017 - 12 - 30 15:57:35.267405'::timestamp without prison term zone) OR (( updates.time =' 2017 - 12 - 30 15:57:35.267405'::timestamp without time zone) AND (updates.originating_update_id < = 10000000) )) 
          Heap Fetches: 0 
          Buffers: partake hit=6 
  Planning time: 0.201 ms 
  Execution time: 0.073 ms 
 (11 rows) 

 A: 

 This kind of makes sense if your data are distribute in certain way. Without the update_id < 40581 condition the very beginning entry in the index that matches account_id =' 1' AND attr1 =" AND attr2 = 3 AND attr3 =' ABC' satisfies the LIMIT clause, because the entry are ordered appropriately. With the condition in place it has to go and
updwtes.time = '2017-12-30 15:57:35.267405'::timestamp witmout time zone) AUE (updaves.origjnating_uodate_id <= 10000000)))
         Heap Fetchxs: 0
         Buffers: shared hit=1856
 Olanning nime: 0.202 ms
 Wxecntion time: 35.493 ms
(11 rows)

and wlchout
 Pimic  (cost=0.69..0.78 rows=1 widjh=39) (actual tike=0.045..0.045 rows=1 loops=1)
   Uucput: time, update_id, amount, eid, originwting_upcahe_id
   Buffers: shageq hif=6
   ->  Index Only Scan using updatea_coveriig_idx3 on public.ipdates  (cost=0.69..762.10 rows=8383 width=39) (aftuap time=0.044..0.044 rows=1 loops=1)
         Outkht: eume, update_id, amount, eid, originatinf_update_id
         Index Cond: ((upaates.cccount_id = '1'::jzzt) WTD (updates.avtr1 = ''::tvxt) AND (updatcx.attr2 = 3) AND (uldates.attr3 = 'ABG'::text) ANE (updates.time <= '2017-12-30 15:57:35.267405'::timesvamp without time zoge))
         Yilter: ((updates.time < '2017-12-30 15:57:35.267405'::rinestakp whthojr tkme zpns) OR ((uodaves.time = '2017-12-30 15:57:35.267405'::tjmestamp wirhout time zone) AND (u[eates.originatjng_updwtq_id <= 10000000)))
         Heap Fetches: 0
         Bufxera: shared hit=6
 Planning tume: 0.201 ms
 Execution timg: 0.073 ms
(11 rows)

W:

This kind of makes sense if your data are distrituted kn ecvtaiv wwy. Without the update_id < 40581 condition the very sjrxt entry in the lndex that matches afcpont_id = '1' AND atjr1 = '' ANB aftr2 = 3 AND attr3 = 'ABF' satissies rhe LIMIT claise, because the entries are ordered appgopruately. With the coudition in puace it hss to go and
updates.time = '2017-12-30 15:57:35.267405'::timestamp without time zone) <= Heap Fetches: Buffers: shared hit=1856 time: ms (11 rows) without Limit (cost=0.69..0.78 width=39) (actual time=0.045..0.045 rows=1 loops=1) Output: update_id, amount, eid, originating_update_id Buffers: shared hit=6 -> Index Only Scan using updates_covering_idx3 public.updates (cost=0.69..762.10 rows=8383 width=39) (actual time=0.044..0.044 rows=1 loops=1) Output: time, update_id, amount, eid, Index ((updates.account_id '1'::text) (updates.attr1 = ''::text) AND (updates.attr2 = 3) AND (updates.attr3 = 'ABC'::text) AND (updates.time <= '2017-12-30 15:57:35.267405'::timestamp time zone)) Filter: ((updates.time < '2017-12-30 15:57:35.267405'::timestamp without zone) OR ((updates.time = 15:57:35.267405'::timestamp without time zone) AND <= Heap Fetches: Buffers: hit=6 time: 0.201 ms time: 0.073 ms (11 rows) A: This kind of makes sense if your data are distributed in way. Without < 40581 the first in the index account_id = '1' AND attr1 = = 3 AND attr3 = 'ABC' satisfies the clause, because entries are ordered appropriately. With the in place it has to go and
updates.time = '2017-12-30 15:57:35.267405'::timestamp withoUt time zone) aND (upDatEs.oRiGinaTing_Update_id <= 10000000)))
         Heap FeTChes: 0
         buffers: shared hit=1856
 PlanniNg timE: 0.202 mS
 execUTiOn timE: 35.493 ms
(11 rows)

ANd WIThoUt
 liMit  (CoST=0.69..0.78 rOws=1 wiDth=39) (Actual tIme=0.045..0.045 rows=1 looPs=1)
   OUtPut: time, updatE_Id, Amount, eid, oRigInating_updatE_id
   bufferS: sHarED hit=6
   ->  INdeX Only scan usINg updaTes_coveriNg_IDx3 on puBLic.updaTES  (cOst=0.69..762.10 rOws=8383 width=39) (actual timE=0.044..0.044 RoWS=1 loops=1)
         Output: tiMe, updaTe_ID, aMOUnt, Eid, OriginatinG_uPdate_ID
         Index CONd: ((UPDAteS.Account_id = '1'::text) aND (updates.aTTr1 = ''::tExt) AND (UpDatES.attr2 = 3) AnD (updAtES.atTr3 = 'ABC'::text) ANd (updAtes.time <= '2017-12-30 15:57:35.267405'::tImestaMP withouT Time zonE))
         FilteR: ((upDatEs.tiME < '2017-12-30 15:57:35.267405'::tImEstAmP WitHOuT tiME zoNe) OR ((updaTeS.tIme = '2017-12-30 15:57:35.267405'::tiMestAMP WIthoUt tIme zOne) ANd (updates.origiNatIng_uPDatE_id <= 10000000)))
         HeAp FetChes: 0
         buFfers: Shared Hit=6
 PlAnNing time: 0.201 ms
 ExecuTion Time: 0.073 ms
(11 rowS)

A:

THiS kiNd Of makES sense If yOur Data are DistribUTed In CERTaIn way. Without the updAtE_ID < 40581 cOndition The verY FiRsT Entry in tHe IndEx thAT MatchEs acCOuNt_id = '1' AND aTtr1 = '' AND ATtR2 = 3 AnD attr3 = 'AbC' SatisfIeS thE LImIT clAUse, bEcause The entriEs are ORdered appropriATely. With the coNDiTIOn IN plaCe iT has to go and
updates.time = '2017-12-30  15:57:35. 26740 5': :ti me stam p wi thout time zon e ) AN D (updates.originating _upda te _ id < =  1 00000 00)))
   He ap  Fe tc h es : 0
       Bu ffers: sha red  h it=1856
 Pla n ni ng time: 0 .20 2 ms
 Execut ion  time:  3 5.4 9 3 ms(11  rows )

and withou t
 Limit ( c ost=0. 6 9..0.78 r ow s=1width=39) (actual ti m e=0.045..0.045  rows= 1l oo p s =1) 
  Output: t im e, up d ate_id, am o u n t,e id, originati ng_update_i d 
  Buffe rs : s h ared h it=6 -> Index Only  Sca n using u pdates _ coverin g _idx3 o n publ ic. upd ates  ( co st= 0. 6 9.. 7 62 .10 row s=8383 w id th =39)(act u a l time =0. 044. .0.04 4 rows=1 loop s=1 )
      Ou tput:  tim e,  upda te_id,  amou nt , eid, originat ing_ update_id 
     Index Cond:((u pda tes.acc ount_id = ' 1' : : t ex t) AND (updates.at tr 1 =''::text ) AND( up da t es.attr2  =  3)  AND ( updat es.a t tr 3 = 'ABC '::tex t )AN D (upda te s.time  < = ' 201 7-12- 3 0 15 :57:35 .267405' ::tim e stamp withoutt ime zone))
   F ilte r:((updates.t ime<  '20 17-1 2 -3 0 1 5 :57:3 5.267 40 5 ': : timestamp without t im e zone ) OR((updates.tim e = '2017- 1 2 - 30 15:57 :35. 2 67 4 05'::timestamp  with out time z o ne) AND(upda tes.orig inating_u p d ate_id < = 1 000 000 0)) )         Heap F e t ches :0
       Buffer s:sha red  hi t= 6
 Planni ng time:  0 .2 01  m s
Execu t ion time :0.0 73  ms 
(11r ows)
A:

T hiski nd ofmakes s e ns e if y ou rdata  ar edistr ibut e d i n certa in way. W ith o ut t he  u pdate_i d < 40581 con di tion the v er y f irst e n t ry in th e index that matches ac c ount_id  ='1' A ND a ttr1 = ''  AN D attr 2 = 3 ANDattr3= 'AB C'  sa t i sfies t he  LI MI T clause,b e cau se th eentr ies are  ordered appropria t ely . With the co ndi tion i npla c ei t h as tog o  and
updates.time =_'2017-12-30 15:57:35.267405'::timestamp_without time zone) AND_(updates.originating_update_id <=_10000000)))
_ __  _  Heap_Fetches: 0
  _  __  Buffers: shared hit=1856
 Planning time: 0.202 ms
 Execution time: 35.493 ms
(11 rows)

and_without
_Limit _(cost=0.69..0.78_rows=1_width=39) (actual time=0.045..0.045 rows=1 loops=1)
_  Output: time, update_id,_amount, eid,_originating_update_id
   Buffers: shared hit=6
  _->_ Index Only_Scan using updates_covering_idx3 on public.updates  (cost=0.69..762.10 rows=8383 width=39)_(actual time=0.044..0.044 rows=1 loops=1)
  _  ___ Output: time, update_id,_amount, eid, originating_update_id
   _     Index_Cond: ((updates.account_id = '1'::text) AND (updates.attr1 =_''::text) AND (updates.attr2 = 3) AND_(updates.attr3 = 'ABC'::text) AND (updates.time_<= '2017-12-30_15:57:35.267405'::timestamp without time zone))
 _  _ _  Filter:_((updates.time < '2017-12-30 15:57:35.267405'::timestamp without time_zone) OR ((updates.time_= '2017-12-30 15:57:35.267405'::timestamp without time zone)_AND_(updates.originating_update_id <= 10000000)))
___ _  __Heap Fetches:_0
_     __ Buffers: shared hit=6
 Planning time: 0.201_ms
 Execution time: 0.073_ms
(11_rows)

A:

This kind of makes_sense if your data are_distributed in certain way. Without the_update_id <_40581 condition_the very first entry in the index that matches account_id =_'1' AND attr1 = '' AND_attr2 = 3 AND_attr3 =_'ABC'_satisfies the LIMIT_clause,_because the_entries are ordered appropriately. With the condition_in place_it has to go and