Re: An Analyze question - Mailing list pgsql-admin

From Nick Fankhauser
Subject Re: An Analyze question
Date
Msg-id NEBBLAAHGLEEPCGOBHDGKEDOENAA.nickf@ontko.com
Whole thread Raw
In response to Re: An Analyze question  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: An Analyze question
List pgsql-admin
> select attname,attdispersion,s.*
> from pg_statistic s, pg_attribute a, pg_class c
> where starelid = c.oid and attrelid = c.oid and staattnum = attnum
> and relname = 'actor_case_assignment';
>
> in each database?
Here are the results:


The "Before" database:

         attname          | attdispersion | starelid | staattnum | staop |
stanullfrac | stacommonfrac | stacommonval  |          staloval           |
stahival
--------------------------+---------------+----------+-----------+-------+--
-----------+---------------+---------------+-----------------------------+--
---------------------
 actor_id                 |    0.00761992 |  2591915 |         1 |  1066 |
0 |     0.0335872 | JTW           | 18105A08315 49              | XS
 case_id                  |    1.4583e-05 |  2591915 |         2 |  1066 |
0 |   7.28935e-05 | 501CP00243    | 02145556                    | YW02647802
 assigned_case_role       |      0.100296 |  2591915 |         6 |  1066 |
0.000108355 |      0.250493 | DEFENDANT     | Attorney                    |
THIRD PARTY PLAINTIFF
 actor_case_assignment_id |            -1 |  2591915 |        17 |  1066 |
0 |   9.85048e-07 | X693CF00396-S | 18105A100DF00438-S-17369 53 | XTV8605
685E-S
(4 rows)



The "After" database:

         attname          | attdispersion | starelid | staattnum | staop |
stanullfrac | stacommonfrac |    stacommonval    |          staloval
|       stahival
--------------------------+---------------+----------+-----------+-------+--
-----------+---------------+--------------------+---------------------------
-+-----------------------
 actor_id                 |       0.03247 | 33979335 |         1 |  1066 |
0 |      0.112092 | 18105XS            | 18105A                     |
18105XS
 case_id                  |   1.22202e-05 | 33979335 |         2 |  1066 |
0 |    6.1086e-05 | 18105498CP01613    | 1810502145556              |
18105YW02647802
 assigned_case_role       |     0.0575305 | 33979335 |         6 |  1066 |
0.000108378 |      0.170868 | Attorney           | Attorney
| THIRD PARTY PLAINTIFF
 actor_case_assignment_id |            -1 | 33979335 |        17 |  1066 |
0 |   9.85259e-07 | 18105X202CM01929-S | 18105A100CF00018-1-7888 53 |
18105XTV8605 685E-S
(4 rows)


> Are you really comparing apples to apples here?

You're correct, but in this case the plans are the same if I use the value
you suggest. The value I'm searching for is not a common one, so presumably,
I'm getting the dispersion for a value that isn't the "most-common-value".

The records in this table fall into three categories generally:

Judges that have ten thousands of cases-
Attorneys that have thousands of cases-
Average Joes who have one or two cases-

This means that a typical actor_id will have one record, but the average is
probably about 2000.

Thanks!

-Nick


pgsql-admin by date:

Previous
From: Tom Lane
Date:
Subject: Re: An Analyze question
Next
From: Denny-Schierz
Date:
Subject: Linux user www-data has no access to amphora2 DB