在此查询中建议使用哪些索引?

时间:2014-07-23 20:42:39

标签: indexing

我正在使用postgres和mysql(myisam和innodb)中的tpc-h基准测试,我已经正确地运行了所有查询,但是我必须使用索引再次运行它们,所以我可以看看它们是否有用不是执行时间。我的问题是Q2,如下:

select
    s_acctbal,
    s_name,
    n_name,
    p_partkey,
    p_mfgr,
    s_address,
    s_phone,
    s_comment
from
    part,
    supplier,
    partsupp,
    nation,
    region
where
    p_partkey = ps_partkey
    and s_suppkey = ps_suppkey
    and p_size = 35
    and p_type like '%STEEL'
    and s_nationkey = n_nationkey
    and n_regionkey = r_regionkey
    and r_name = 'EUROPE'
    and ps_supplycost = (
        select
            min(ps_supplycost)
        from
            partsupp,
            supplier,
            nation,
            region
        where
            p_partkey = ps_partkey
            and s_suppkey = ps_suppkey
            and s_nationkey = n_nationkey
            and n_regionkey = r_regionkey
            and r_name = 'EUROPE'
    )
order by
    s_acctbal desc,
    n_name,
    s_name,
    p_partkey

nationregions是分别有20行和5行的小表,因此它们不需要索引,但其他表使用默认索引(pk one),这些索引可以加快查询执行时间吗?

谢谢!

0 个答案:

没有答案
相关问题