Q

# Tune this complex WHERE clause

## How do we tune the following where clause?

How do we tune the following where clause:

``` (  shipper_id
IN (select organization_id from orgrelation
where act_as_to_org_id = 900009
union
select 900009 from dual)
OR consignee_id
IN (select organization_id from orgrelation
where act_as_to_org_id = 900009
union
select 900009 from dual)
OR freight_payer_id
IN (select organization_id from orgrelation
where act_as_to_org_id = 900009
union
select 900009 from dual)
OR beneficial_owner_id
IN (select organization_id from orgrelation
where act_as_to_org_id = 900009
union
select 900009 from dual)
OR care_of_party_id
IN (select organization_id from orgrelation
where act_as_to_org_id = 900009
union
select 900009 from dual)
OR notify_party_id
IN (select organization_id from orgrelation
where act_as_to_org_id = 900009
union
select 900009 from dual)
OR property_owner_id
IN (select organization_id from orgrelation
where act_as_to_org_id = 900009
union
select 900009 from dual)
)```

Let's look at this portion of the IN subquery --

```select organization_id from orgrelation
where act_as_to_org_id = 900009  ```

Notice that this is exactly the same query in every IN clause. Now, if this query returns exactly one row, then you can simplify your big complex WHERE condition like this --

``` (  (select organization_id from orgrelation
where act_as_to_org_id = 900009 )
IN ( shipper_id
, consignee_id
, freight_payer_id
, beneficial_owner_id
, care_of_party_id
, notify_party_id
, property_owner_id  )
OR 900009
IN ( shipper_id
, consignee_id
, freight_payer_id
, beneficial_owner_id
, care_of_party_id
, notify_party_id
, property_owner_id  )
)```

This isn't actually "tuning" but it does simplify things a little.

This was last published in June 2006

## Content

Find more PRO+ content and other member only offers, here.

#### Have a question for an expert?

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

#### Start the conversation

Send me notifications when other members comment.

## SearchDataManagement

• ### Graph data model cements tight relationships between data elements

Graph databases can help define and discover relationships between entities -- and offer increased flexibility and better ...

• ### Microsoft SQL Server 2016 relational DBMS overview

Microsoft SQL Server 2016 for Windows comes in four editions, with updates that include a new stretch database feature, Polybase,...

• ### Amazon ushers in pay-by-query pricing with Athena data engine

Amazon's Athena data engine brings interactive SQL queries to S3. It's based on an open source framework called Presto that ...

• ### Creative projects leave people guessing about future impact of AI

A push is underway to write creative AI algorithms that can engage in music, film and design projects. So far, they have ...

• ### Data visualization plays an important role in a big data environment

Enterprises are increasingly putting data visualization tools, like Tableau, at the top of their big data platforms to start ...

## SearchSAP

• ### Does SAP ONE Support Launchpad make SAP support any easier to use?

The new Fiori user experience makes it easier to access applications and support services, but product-specific support still ...

• ### At SME Summit, SAP Anywhere growing pains revealed

Attendees at an SAP SME Summit lauded the e-commerce front end, but some said back-end integration and payment-processing ...

• ### Planning a HANA big data strategy with SAP HANA Vora

SAP has worked hard to position HANA as a big data platform. To formulate a viable big data strategy, you need to know the tools,...

## SearchSQLServer

• ### SQL Server on Linux signals Microsoft's changing development landscape

Expert Joey D'Antoni explains what SQL Server on Linux and the addition of Enterprise Edition features to Standard Edition say ...

• ### How to get the most out of virtual SQL Server with Microsoft Hyper-V

SQL Server is a CPU-intensive technology, which can make it tricky to run in a virtualized environment. Keep your SQL Server ...

• ### Microsoft previews SQL Server on Linux, opens features across editions

Microsoft looks to broaden the horizons of SQL Server, as it moves some Enterprise features to Standard Edition and issues the ...

## TheServerSide

• ### How to turn your DevOps failures into ALM successes

Doing the right thing doesn't always mean you're doing things right. But don't fret, because short-term DevOps failures can mean ...

• ### From chatbots to IBM's Watson: How software deals with conversational language

The next big thing in software development is conquering the conversational language development hurdle. Here's how the big ...

• ### Getting through the three toughest stages of a DevOps transition

Looking to gain increased productivity and software quality by embracing DevOps? Here are the DevOps transitions your company ...

## SearchDataCenter

• ### Telcos purge colocation data centers, open door to neutral connections

Enterprise customers in Verizon and CenturyLink's colocation data centers should expect better cloud and network connection ...

• ### IT slowly embraces composable infrastructure

If there will be a way to make an enterprise data center as efficient and optimized as cloud computing, composable infrastructure...

• ### Examine data collection problems with big data, IoT in mind

Networking challenges and data collection problems can occur when IT tries to deploy IoT and big data into a data center. ...

## SearchContentManagement

• ### Users prefer Office 365 suite collaboration features over SharePoint

Users don't want to jump through hoops, and they want applications to work on mobile devices. Those needs may kill traditional ...

• ### What new SharePoint features to expect in the next 12 months

Now that Microsoft is developing its SharePoint features, there are new feature rollouts all the time. Here's a rundown of the ...

• ### How WCM and AI promote smart digital user experiences

Digital user experiences and other business processes are poised to become much richer with artificial intelligence at the helm.

## SearchFinancialApplications

• ### Project planning for a new corporate performance management system

A corporate performance management system touches most aspects of any business. You need a carefully thought-out plan to ensure a...

• ### No one-size-fits-all strategy for cloud ERP software migration

Experts say a cloud ERP transition plan will vary according to a variety of factors, from company size to an organization's ...

• ### HR video apps spreading beyond training to recruiting, engagement

Users say cost savings, faster turnaround and better corporate branding are some of the benefits from using video at more stages ...

Close