Home » RDBMS Server » Performance Tuning » Help to split query
Help to split query [message #181807] Tue, 11 July 2006 11:25 Go to next message
mape
Messages: 298
Registered: July 2006
Location: Slovakia
Senior Member
Hello

I would like to split this query to smallest one,
but I dont know how to do it?
Can you help me?

thanks a lot

---------------------------------------------------------------
SELECT /*+ ALL_ROWS */
       su.x_external_id || CHR (9) || ofr.x_offer_id
  FROM table_site_part su, table_site_part svc, table_x_csr_offer_cfg ofr
 WHERE svc.site_part2site_part = su.objid
   AND ofr.x_offer_id <> '457021455'
   AND ofr.x_csr_offer_cfg2service = svc.site_part2part_info
   AND ofr.x_export_event = 1
   AND su.x_site_part2status_su = 268488358
   AND EXISTS (
          SELECT 'X'
            FROM table_bus_org cu, table_site eu, table_site_part su
           WHERE su.site_part2site = eu.objid
             AND eu.x_site2customer = cu.objid
             AND cu.x_bus_org2billcycle BETWEEN 268442453 AND 268442456
          UNION ALL
          SELECT 'X'
            FROM table_bus_org cu, table_site eu, table_site_part su
           WHERE su.site_part2site = eu.objid
             AND eu.x_site2customer = cu.objid
             AND cu.x_bus_org2billcycle = 268451297)
   AND (   ofr.x_tariff_sensitive = 0
        OR (       ofr.x_tariff_sensitive = 1
               AND ofr.x_csr_offer_cfg2tariff =
                      (SELECT x_tariff_detail2tariff
                         FROM table_x_tariff_detail
                        WHERE x_tarif_detail2site_part = su.objid
                          AND x_active = 1)
            OR (    ofr.x_tariff_sensitive = 1
                AND ofr.x_csr_offer_cfg2tariff IS NULL
                AND NOT EXISTS (
                       SELECT 'X'
                         FROM table_x_csr_offer_cfg ofr2,
                              table_site_part su,
                              table_site_part svc,
                              table_x_tariff_detail td
                        WHERE svc.site_part2part_info =
                                                  ofr2.x_csr_offer_cfg2service
                          AND ofr2.x_tariff_sensitive = 1
                          AND su.objid = td.x_tarif_detail2site_part
                          AND td.x_active = 1
                          AND ofr2.x_csr_offer_cfg2tariff =
                                                     td.x_tariff_detail2tariff
                          AND ofr2.x_tariff_sensitive = td.x_active)
               )
           )
       )
   AND (   ofr.x_param_sensitive = 0
        OR EXISTS (
              SELECT 'X'
                FROM table_fa_site_part par, table_x_csr_param_value pv
               WHERE par.fa_site_part2site_part = svc.objid
                 AND par.fa_site_part2flex_defn = ofr.x_param_def_objid
                 AND pv.objid = ofr.x_csr_offer_cfg2par_value
                 AND par.attribute_value = pv.x_value)
       )
   AND (   svc.x_site_part2status_su = 805307984
        OR (    svc.x_site_part2status_su = 805307985
            AND ofr.x_suspend_sensitive = 0
           )
       )

----------------------------------------------------------------
Re: Help to split query [message #181869 is a reply to message #181807] Wed, 12 July 2006 00:26 Go to previous messageGo to next message
nmacdannald
Messages: 460
Registered: July 2005
Location: Stockton, California - US...
Senior Member
try them seperate:
try:
SELECT 'X'
FROM table_bus_org cu, table_site eu, table_site_part su
WHERE su.site_part2site = eu.objid
AND eu.x_site2customer = cu.objid
AND cu.x_bus_org2billcycle BETWEEN 268442453 AND 268442456
then try:
SELECT 'X'
FROM table_bus_org cu, table_site eu, table_site_part su
WHERE su.site_part2site = eu.objid
AND eu.x_site2customer = cu.objid
AND cu.x_bus_org2billcycle = 268451297)
Then:
SELECT 'X'
FROM table_x_csr_offer_cfg ofr2,
table_site_part su,
table_site_part svc,
table_x_tariff_detail td
WHERE svc.site_part2part_info =
ofr2.x_csr_offer_cfg2service
AND ofr2.x_tariff_sensitive = 1
AND su.objid = td.x_tarif_detail2site_part
AND td.x_active = 1
AND ofr2.x_csr_offer_cfg2tariff =
td.x_tariff_detail2tariff
AND ofr2.x_tariff_sensitive = td.x_active)

And so on. It looks easy to split your query. I usually split a query when it is very dificult to make sure I get the correct response.
Neil.
Re: Help to split query [message #181882 is a reply to message #181807] Wed, 12 July 2006 01:54 Go to previous message
mape
Messages: 298
Registered: July 2006
Location: Slovakia
Senior Member

I would like to split this query for example on 2 query
and after run both of query I will get the same result

Thats what I would I do.

Thanks for help
Previous Topic: URGENT-Shadow process memory usage growth
Next Topic: Performance deleting rows
Goto Forum:
  


Current Time: Sat Nov 23 12:48:18 CST 2024