Oracle—使用EAV(实体属性值)设计,我应该如何使用存储在表中的字段值加速Oracle表查询的页面加载?
问题摘要Oracle—使用EAV(实体属性值)设计,我应该如何使用存储在表中的字段值加速Oracle表查询的页面加载?,oracle,performance,asynchronous,query-optimization,Oracle,Performance,Asynchronous,Query Optimization,问题摘要 SELECT t1.tablefield, t1.tableid, t1.fieldname as license t2.fieldname as state t3.fieldname as excluded FROM tableofdata t1, tableofdata t2, tableofdata t3 WHERE t1.org = :location AN
SELECT t1.tablefield,
t1.tableid,
t1.fieldname as license
t2.fieldname as state
t3.fieldname as excluded
FROM
tableofdata t1,
tableofdata t2,
tableofdata t3
WHERE
t1.org = :location
AND t2.org = :t1.org
AND t1.customer = t2.customer
AND t1.sequence = t2.sequence
AND t1.sequence2 = t2.sequence2
AND t3.org = t2.org
AND t3.customer = t2.customer
AND t1.code = 'license'
AND t2.code = 'state'
AND t3.code = 'status'
AND t1.value = :license
AND t2.value = :state
AND t3.value = 'Excluded';
我在PHP中的web应用程序上有一个页面,当页面加载时,页面会在加载时暂停很多。目前有一个查询,它获取一个页面上的记录,一个页面上的单个记录,总计约160条记录。当我在这个循环记录获取(下面的查询)中添加一个查询时,每个记录获取在单个获取上大约需要20-30秒
当前配置
我们的应用程序不拥有或托管数据库,它只可以查询web PHP应用程序中的记录,并且我们无权添加索引或更改存储过程等
瓶颈查询
SELECT t1.tablefield,
t1.tableid,
t1.fieldname as license
t2.fieldname as state
t3.fieldname as excluded
FROM
tableofdata t1,
tableofdata t2,
tableofdata t3
WHERE
t1.org = :location
AND t2.org = :t1.org
AND t1.customer = t2.customer
AND t1.sequence = t2.sequence
AND t1.sequence2 = t2.sequence2
AND t3.org = t2.org
AND t3.customer = t2.customer
AND t1.code = 'license'
AND t2.code = 'state'
AND t3.code = 'status'
AND t1.value = :license
AND t2.value = :state
AND t3.value = 'Excluded';
如何解决此问题?
A)优化查询?
表上存在哪些索引?正如您在请求中所说的MySQL,这似乎是关于MySQL的,而不是关于Oracle的。我已经删除了Oracle标签。如果这是关于Oracle而不是MySQL,请更改您的请求文本和标记。表设计看起来很糟糕。某种超通用键值?这真的是同一张桌子的三倍吗?这在一定程度上可以解释为什么它这么慢。但是你是说,你一行一行地取,每行需要20秒?你是怎么做到的?你不能一次获取所有行吗?这可能会有所帮助,你是否展示了一些示例数据,以便我们了解网站应该从表中检索哪些不同行。这个问题似乎是“为什么不使用EAV”问题的可能答案