explain.depesz.com

PostgreSQL's explain analyze made readable

Result: trVy

Settings
# exclusive inclusive rows x rows loops node
1. 0.018 2,374.465 ↑ 1.0 1 1

Aggregate (cost=6,524.35..6,524.36 rows=1 width=32) (actual time=2,374.465..2,374.465 rows=1 loops=1)

  • Output: CASE WHEN (NOT $4) THEN NULL::text WHEN $5 THEN 'red'::text ELSE CASE WHEN (((count(DISTINCT (opendoorrecord.opentime)::date) FILTER (WHERE ((opendoorrecord.opentime)::text > (((timezone('PRC'::text, now()) - '30 days'::interval))::date)::text)) >= 5) IS TRUE) AND bool_or(((opendoorrecord.opentime)::text < (((timezone('PRC'::text, now()) - '90 days'::interval))::date)::text))) THEN 'green'::text ELSE 'yellow'::text END END
2.          

CTE keys

3. 153.402 905.283 ↓ 1.7 72 1

Gather (cost=1,000.42..6,435.60 rows=43 width=108) (actual time=905.142..905.283 rows=72 loops=1)

  • Output: keyhistoryinfo.houseid, keyhistoryinfo.lockid, (COALESCE(keyhistoryinfo.keyholder, keyhistoryinfo.useraccount))
  • Workers Planned: 2
  • Workers Launched: 2
4. 0.000 751.881 ↑ 1.8 24 3 / 3

Parallel Append (cost=0.42..5,431.30 rows=43 width=108) (actual time=467.157..751.881 rows=24 loops=3)

  • Worker 0: actual time=496.370..676.146 rows=15 loops=1
  • Worker 1: actual time=1.313..675.699 rows=56 loops=1
5. 0.211 380.312 ↓ 1.4 24 3 / 3

Nested Loop (cost=0.42..3,013.59 rows=17 width=108) (actual time=95.447..380.312 rows=24 loops=3)

  • Output: keyhistoryinfo.houseid, keyhistoryinfo.lockid, COALESCE(keyhistoryinfo.keyholder, keyhistoryinfo.useraccount)
  • Inner Unique: true
  • Worker 0: actual time=51.537..231.311 rows=15 loops=1
  • Worker 1: actual time=1.313..675.686 rows=56 loops=1
6. 379.525 379.525 ↑ 1.6 24 3 / 3

Parallel Seq Scan on alpubdb.keyhistoryinfo (cost=0.00..2,989.53 rows=38 width=74) (actual time=94.997..379.525 rows=24 loops=3)

  • Output: keyhistoryinfo.keyid, keyhistoryinfo.lockid, keyhistoryinfo.useraccount, keyhistoryinfo.authaccount, keyhistoryinfo.startdate, keyhistoryinfo.expireddate, keyhistoryinfo.keytype, keyhistoryinfo.keystate, keyhistoryinfo.holdkeynum, keyhistoryinfo.userrole, keyhistoryinfo.freezelabel, keyhistoryinfo.openmode, keyhistoryinfo.openpwd, keyhistoryinfo.applytime, keyhistoryinfo.authtime, keyhistoryinfo.stoptime, keyhistoryinfo.operator, keyhistoryinfo.address, keyhistoryinfo.keyholder, keyhistoryinfo.keysign, keyhistoryinfo.houseid, keyhistoryinfo.memo, keyhistoryinfo.id
  • Filter: ((keyhistoryinfo.userrole <> 255) AND (('15157236362'::text = (keyhistoryinfo.keyholder)::text) OR ('15157236362'::text = (keyhistoryinfo.useraccount)::text)))
  • Rows Removed by Filter: 86220
  • Worker 0: actual time=51.481..231.170 rows=15 loops=1
  • Worker 1: actual time=0.035..673.921 rows=56 loops=1
7. 0.576 0.576 ↑ 1.0 1 72 / 3

Index Scan using houseinfo_pkey on alpubdb.houseinfo (cost=0.42..0.63 rows=1 width=35) (actual time=0.024..0.024 rows=1 loops=72)

  • Output: houseinfo.houseid, houseinfo.customid, houseinfo.housedirid, houseinfo.ownername, houseinfo.ownerphone, houseinfo.ownerid, houseinfo.regionaddr, houseinfo.villagetown, houseinfo.community, houseinfo.street, houseinfo.xqname, houseinfo.building, houseinfo.unit, houseinfo.detailaddr, houseinfo.longitude, houseinfo.latitude, houseinfo.area, houseinfo.housetype, houseinfo.maxpeople, houseinfo.rent, houseinfo.photo1, houseinfo.photo2, houseinfo.photo3, houseinfo.photo4, houseinfo.housestatus, houseinfo.housenumber, houseinfo.xqpcs, houseinfo.gldwdm, houseinfo.xzqhdm, houseinfo.jwq, houseinfo.jwqdm, houseinfo.letdate, houseinfo.agentname, houseinfo.agentphone, houseinfo.agentid, houseinfo.lockfee, houseinfo.modifytime, houseinfo.memo, houseinfo.createmanageruserid, houseinfo.createtime, houseinfo.modifymangeuserid
  • Index Cond: ((houseinfo.houseid)::text = (keyhistoryinfo.houseid)::text)
  • Filter: ((houseinfo.xzqhdm)::text ~~ '330522%'::text)
  • Worker 0: actual time=0.007..0.007 rows=1 loops=15
  • Worker 1: actual time=0.029..0.029 rows=1 loops=56
8. 0.001 371.708 ↓ 0.0 0 2 / 3

Nested Loop (cost=0.42..2,417.07 rows=1 width=112) (actual time=557.562..557.562 rows=0 loops=2)

  • Output: lockkeyinfo.houseid, lockkeyinfo.lockid, COALESCE(lockkeyinfo.keyholder, lockkeyinfo.useraccount)
  • Inner Unique: true
  • Worker 0: actual time=444.831..444.831 rows=0 loops=1
9. 371.707 371.707 ↓ 0.0 0 2 / 3

Parallel Seq Scan on alpubdb.lockkeyinfo (cost=0.00..2,415.79 rows=2 width=78) (actual time=557.561..557.561 rows=0 loops=2)

  • Output: lockkeyinfo.keyid, lockkeyinfo.lockid, lockkeyinfo.useraccount, lockkeyinfo.houseid, lockkeyinfo.authaccount, lockkeyinfo.startdate, lockkeyinfo.expireddate, lockkeyinfo.keytype, lockkeyinfo.freezelabel, lockkeyinfo.keystate, lockkeyinfo.holdkeynum, lockkeyinfo.userrole, lockkeyinfo.openmode, lockkeyinfo.openpwd, lockkeyinfo.applytime, lockkeyinfo.authtime, lockkeyinfo.enableflag, lockkeyinfo.keyholder, lockkeyinfo.keysign, lockkeyinfo.memo, lockkeyinfo.confirmkeytime
  • Filter: ((lockkeyinfo.userrole <> 255) AND (('15157236362'::text = (lockkeyinfo.keyholder)::text) OR ('15157236362'::text = (lockkeyinfo.useraccount)::text)))
  • Rows Removed by Filter: 102556
  • Worker 0: actual time=444.830..444.830 rows=0 loops=1
10. 0.000 0.000 ↓ 0.0 0 / 3

Index Scan using houseinfo_pkey on alpubdb.houseinfo houseinfo_1 (cost=0.42..0.64 rows=1 width=35) (never executed)

  • Output: houseinfo_1.houseid, houseinfo_1.customid, houseinfo_1.housedirid, houseinfo_1.ownername, houseinfo_1.ownerphone, houseinfo_1.ownerid, houseinfo_1.regionaddr, houseinfo_1.villagetown, houseinfo_1.community, houseinfo_1.street, houseinfo_1.xqname, houseinfo_1.building, houseinfo_1.unit, houseinfo_1.detailaddr, houseinfo_1.longitude, houseinfo_1.latitude, houseinfo_1.area, houseinfo_1.housetype, houseinfo_1.maxpeople, houseinfo_1.rent, houseinfo_1.photo1, houseinfo_1.photo2, houseinfo_1.photo3, houseinfo_1.photo4, houseinfo_1.housestatus, houseinfo_1.housenumber, houseinfo_1.xqpcs, houseinfo_1.gldwdm, houseinfo_1.xzqhdm, houseinfo_1.jwq, houseinfo_1.jwqdm, houseinfo_1.letdate, houseinfo_1.agentname, houseinfo_1.agentphone, houseinfo_1.agentid, houseinfo_1.lockfee, houseinfo_1.modifytime, houseinfo_1.memo, houseinfo_1.createmanageruserid, houseinfo_1.createtime, houseinfo_1.modifymangeuserid
  • Index Cond: ((houseinfo_1.houseid)::text = (lockkeyinfo.houseid)::text)
  • Filter: ((houseinfo_1.xzqhdm)::text ~~ '330522%'::text)
11.          

Initplan (for Aggregate)

12. 0.001 0.001 ↑ 43.0 1 1

CTE Scan on keys keys_1 (cost=0.00..0.86 rows=43 width=0) (actual time=0.001..0.001 rows=1 loops=1)

13. 15.521 1,466.174 ↓ 0.0 0 1

Hash Join (cost=1.82..3,318.35 rows=39 width=0) (actual time=1,466.174..1,466.174 rows=0 loops=1)

  • Hash Cond: ((billrecord.lockid)::text = (keys_2.lockid)::text)
14. 1,450.595 1,450.595 ↑ 1.1 33,027 1

Index Scan using billrecord_billstate_idx on alpubdb.billrecord (cost=0.42..3,178.44 rows=36,832 width=19) (actual time=2.241..1,450.595 rows=33,027 loops=1)

  • Output: billrecord.billid, billrecord.billname, billrecord.houseid, billrecord.customid, billrecord.houseaddr, billrecord.lockid, billrecord.appusername, billrecord.appaccount, billrecord.amount, billrecord.monthlyfee, billrecord.paymonths, billrecord.discountamount, billrecord.billcreatetime, billrecord.billendtime, billrecord.payendtime, billrecord.servicetype, billrecord.paytype, billrecord.billpaydate, billrecord.billstate, billrecord.paymode, billrecord.payername, billrecord.payaccount, billrecord.recipientname, billrecord.recipientaccount, billrecord.poundage, billrecord.poundageparter, billrecord.payno, billrecord.payorderstring, billrecord.paytime, billrecord.payclosetime, billrecord.paystatus, billrecord.errmessage, billrecord.verifystate, billrecord.verifier, billrecord.billoldstate, billrecord.curbillnum, billrecord.verifytime, billrecord.memo, billrecord.createmanageruserid, billrecord.createtime, billrecord.modifymangeuserid, billrecord.modifytime
  • Index Cond: (billrecord.billstate = 0)
  • Filter: ((billrecord.billcreatetime)::text < (((timezone('PRC'::text, now()) - '1 mon'::interval))::date)::text)
  • Rows Removed by Filter: 7190
15. 0.015 0.058 ↓ 1.7 72 1

Hash (cost=0.86..0.86 rows=43 width=98) (actual time=0.058..0.058 rows=72 loops=1)

  • Output: keys_2.lockid
  • Buckets: 1024 Batches: 1 Memory Usage: 12kB
16. 0.043 0.043 ↓ 1.7 72 1

CTE Scan on keys keys_2 (cost=0.00..0.86 rows=43 width=98) (actual time=0.002..0.043 rows=72 loops=1)

  • Output: keys_2.lockid
17. 0.009 908.272 ↓ 0.0 0 1

Hash Join (cost=0.79..1.82 rows=1 width=20) (actual time=908.272..908.272 rows=0 loops=1)

  • Output: opendoorrecord.opentime
  • Hash Cond: ((keys.lockid)::text = (opendoorrecord.lockid)::text)
18. 905.146 905.146 ↑ 43.0 1 1

CTE Scan on keys (cost=0.00..0.86 rows=43 width=98) (actual time=905.146..905.146 rows=1 loops=1)

  • Output: keys.houseid, keys.lockid, keys.userid
19. 0.001 3.117 ↓ 0.0 0 1

Hash (cost=0.78..0.78 rows=1 width=39) (actual time=3.117..3.117 rows=0 loops=1)

  • Output: opendoorrecord.opentime, opendoorrecord.lockid
  • Buckets: 1024 Batches: 1 Memory Usage: 8kB
20. 3.116 3.116 ↓ 0.0 0 1

Index Only Scan using opendoorrecord_userid_lockid_opentime_idx on alpubdb.opendoorrecord (cost=0.56..0.78 rows=1 width=39) (actual time=3.116..3.116 rows=0 loops=1)

  • Output: opendoorrecord.opentime, opendoorrecord.lockid
  • Index Cond: ((opendoorrecord.userid = '15157236362'::text) AND (opendoorrecord.lockid = ANY ('{AILOCK_db38bbf2f8f0}'::text[])))
  • Heap Fetches: 0
Planning time : 1.086 ms
Execution time : 2,375.425 ms