以下是表tenk1的相關(guān)的一部分統(tǒng)計信息。 SELECT relname, relkind, reltuples, relpages FROM pg_class WHERE relname LIKE 'tenk1%';
relname | relkind | reltuples | relpages ----------------------+---------+-----------+---------- tenk1 | r | 10000 | 358 tenk1_hundred | i | 10000 | 30 tenk1_thous_tenthous | i | 10000 | 30 tenk1_unique1 | i | 10000 | 30 tenk1_unique2 | i | 10000 | 30 (5 rows) 其中 relkind是類型,r是自身表,i是索引index;reltuples是項目數(shù);relpages是所占硬盤的塊數(shù)。
3.明確用join來關(guān)聯(lián)表 一般寫法:SELECT * FROM a, b, c WHERE a.id = b.id AND b.ref = c.id; 如果明確用join的話,執(zhí)行時候執(zhí)行計劃相對容易控制一些。 例子: SELECT * FROM a CROSS JOIN b CROSS JOIN c WHERE a.id = b.id AND b.ref = c.id; SELECT * FROM a JOIN (b JOIN c ON (b.ref = c.id)) ON (a.id = b.id);