From: | "DaNieL(dot)(dot)!" <daniele(dot)pignedoli(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Please suggest me on my table design (indexes!) |
Date: | 2009-06-23 13:42:21 |
Message-ID: | fbeef6db-5bcc-4dd0-822d-84a0331c8e49@g1g2000yqh.googlegroups.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
The `problem` is that i dont know if having so many indexes will raise
problems as the data dimension grown.
And i am not even sure that this design is truly reliable;
For example, if i would to know how many employees have every company,
i'll have to run that query:
-----
EXPLAIN ANALYZE
SELECT
c.id,
c.company_name,
count(e.id) AS num_employee
FROM
contact AS c
LEFT JOIN contact AS e ON (c.id = e.id_company)
WHERE c.tipo = 'company'
GROUP BY c.id, c.company_name
-----
That seem to be not very efficient: http://explain.depesz.com/s/Q0m
(I loaded some test data from http://www.generatedata.com/#generator,
so now i have 23893 rows in the table.. oh, i added a index on the
'kind' (tipo) column too)
On 23 Giu, 13:47, gryz(dot)(dot)(dot)(at)gmail(dot)com (Grzegorz Jaśkiewicz) wrote:
> it looks ok on explain, that is - the cost isn't too high.
> So what's the problem ?
>
> --
> Sent via pgsql-general mailing list (pgsql-gene(dot)(dot)(dot)(at)postgresql(dot)org)
> To make changes to your subscription:http://www.postgresql.org/mailpref/pgsql-general
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2009-06-23 13:47:07 | Re: Information about columns |
Previous Message | Dave Page | 2009-06-23 13:30:50 | Re: [BUGS] Integrity check |