sybase中的查询优化
我需要从 22 个客户数据库中检索客户 MSISDN(电话号码)。我为两种情况创建了一个视图:
首先我们需要检查哪个 MSISDN profile_id 16240 处于非活动状态。这可以通过在非活动数据不为空的数据库中查询来完成。
由于 GPRS 有两个配置文件 25054 和 16240,因此对于 MSISDN,25054(用于互联网目的)处于活动状态而 16240(用于 GPRS 未处于活动状态) 因此我们需要为此目的创建脚本。
我准备了一个查询:
CREATE VIEW SUBSCR_INFO_VIEW AS
SELECT subscr_no,account_no FROM CUSTOMER_PROFILE_DEF WHERE subscr_no NOT IN
(SELECT DISTINCT(subscr_no) FROM CUSTOMER_ID_EQUIP_MAP
WHERE inactive_date Is NOT NULL)
AND (profile_id IN (16240) AND cutoff_end_dt IS NOT NULL) OR (profile_id IN (25054) AND profile_id NOT IN (16240) AND cutoff_end_dt IS NULL)
SET ROWCOUNT 100
SELECT DISTINCT(subscr_no) FROM SUBSCR_INFO_VIEW
这将在所有 22 个客户服务器中被命中,并且从单个客户获取数据需要 2.5 分钟。我想减少那个时间。请让我知道您的反馈。
I need to retrieve customer MSISDN (phone no) from 22 customer databases. I have created a view for two cases:
First we need to check for which MSISDNs profile_id 16240 is inactive.This can be done by querying in database whose inactive data is not null.
Since for GPRS we have two profile 25054 and 16240,it happens e for MSISDNs 25054 (for internet purpose) is active and 16240 (for GPRS is not active)
so we need to create script for that purpose .
I have prepared a query:
CREATE VIEW SUBSCR_INFO_VIEW AS
SELECT subscr_no,account_no FROM CUSTOMER_PROFILE_DEF WHERE subscr_no NOT IN
(SELECT DISTINCT(subscr_no) FROM CUSTOMER_ID_EQUIP_MAP
WHERE inactive_date Is NOT NULL)
AND (profile_id IN (16240) AND cutoff_end_dt IS NOT NULL) OR (profile_id IN (25054) AND profile_id NOT IN (16240) AND cutoff_end_dt IS NULL)
SET ROWCOUNT 100
SELECT DISTINCT(subscr_no) FROM SUBSCR_INFO_VIEW
This will be hit in all 22 customer servers and to take data from a single customer it's taking 2.5 min. I want to reduce that time. Please let me know your feedback.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果不了解更多关于数据库结构的信息,这个问题有点难以回答。 CUSTOMER_PROFILE_DEF 和 CUSTOMER_ID_EQUIP_MAP 表中有多少条记录,有哪些键?另外,您的 SQL 在原始帖子中很难理解,我在下面重新格式化了它并做了一些小更改:
sql 基本相同,但我将 (12345) 语句中的
profile_id 更改为
profile_id = 12345
因为值列表中只有一个值。This is a little difficult to answer without knowing more about the structure of the database. How many records do you have in the CUSTOMER_PROFILE_DEF and CUSTOMER_ID_EQUIP_MAP tables, and what keys do you have? Also, your SQL is very difficult to understand in the original post, I have reformatted it below and made some small changes:
The sql is largely the same, but I changed your
profile_id in (12345)
statements toprofile_id = 12345
as there was only one value in the list of values.