public inbox for [email protected]  
help / color / mirror / Atom feed
From: Jian He <[email protected]>
To: pgsql-sql <[email protected]>
Subject: Histogram question.
Date: Tue, 5 Apr 2022 20:04:44 +0530
Message-ID: <CAMV54g17LBTqs069dE5c1EmnGnJXmMtgCNxH5vesjfbJY8_D0g@mail.gmail.com> (raw)

Queries in PostgreSQL: 2. Statistics : Postgres Professional
<https://postgrespro.com/blog/pgsql/5969296;



SELECT sum(s.most_common_freqs[ array_position((s.most_common_vals::text::
text[]),v) ]) FROM pg_stats s, unnest(s.most_common_vals::text::text[]) v
WHERE s.tablename = 'boarding_passes' AND s.attname = 'seat_no';

*return 0.6762. *

SELECT sum(s.most_common_freqs[ array_position((s.most_common_vals::text::
text[]),v) ]) FROM pg_stats s, unnest(s.most_common_vals::text::text[]) v
WHERE s.tablename = 'boarding_passes' AND s.attname = 'seat_no' AND v >
'30C';

return *0.2127*

SELECT round( reltuples * ( 0.2127 -- from most common values + (1 - 0.6762
- 0) * (49 / 100.0) -- from histogram )) FROM pg_class WHERE relname =
'boarding_passes';

the above mentioned query, the part I don't understand is *49/100.*


view thread (2+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: Histogram question.
  In-Reply-To: <CAMV54g17LBTqs069dE5c1EmnGnJXmMtgCNxH5vesjfbJY8_D0g@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox