Re: Too many WHERE conditions?



The SQL statement has
about 10,000 characters, the vast majority of which is 24 repetitive
blocks of SQL, forming the expression in an "IN" statement inside the
WHERE clause (... WHERE id IN ...). I am joining 7 tables together (in
the FROM), some of which can contain millions of records.

You might want get an SQL expert to check it out, see if it is efficient.
Also (if you can), check the indexes for various tables you select from
You also might want to conditionally generate parts of it depending on
customers responses.
I also apply some optimisations for WHERE:
if a list of things contains exactly 1 item , then I say "WHERE id =
item"
and if a list of things is numeric and integral, then I see if the list
of items is the same as maxitem - minitem + 1. If it is then I do "WHERE id
BETWEEN minitem AND maxitem"

Is there a limit on the number of WHERE conditions for an SQL
statement? I am certain that I must have over-complicated the SQL,
since I am not an expert. After all, it works fine in the office, so I
don't understand what could be different at the customer database to
cause such a problem. By the way, I have no access to the customer
database or their setup.

Has your customer got the same version of Oracle as you?
Moveover, has it had all the patches applied (that Oracle issue)?
I would check this out. It could be a bug in Oracle's optimiser that is
fixed in a patch.

On the limit: NAFAIK
I would not worry about too many clauses to WHERE.
Oracle is a sophisticated database of immense strength.
Adding WHERE clauses is good as it cuts down rows considered in the query
and improves performance.

Stephen Howe


.



Relevant Pages

  • ORA-01092: ORACLE instance terminated. Disconnection forced
    ... I know that Oracle recommends AUTO, but I just want to test ... SQL> CREATE TABLESPACE "RBS01" ... Database mounted. ... SQL> CREATE ROLLBACK SEGMENT rollback1 TABLESPACE rbs01 ...
    (comp.databases.oracle.server)
  • Re: Anleitung für Oracle Upgrdae?
    ... To upgrade Oracle databases from a previous release directly to Oracle9i ... For more information about upgrading a database, ... For RAC installations, ensure that there is at least 50 MB of free space ... SQL> SHOW PARAMETER PFILE; ...
    (de.comp.datenbanken.misc)
  • Re: OOP - a question about database access
    ... >>and project so much better in SQL DBMSes than in ODBMSes, ... >>100x more bytes from the database, just because you want your objects to ... > a related invoice.. ... > assoication from the customer to the invoice collection and have done ...
    (comp.object)
  • Re: OOP/OOD Philosophy
    ... > Because if you don't Oracle will print something you don't want to see. ... The database should not print anything at all. ... > Great but this discussion was about Standand SQL. ... Transactions and locking work together. ...
    (comp.object)
  • Re: Selecting from dynamic performance views in PL/SQL
    ... Andreas Sheriff wrote: ... > SQL> DECLARE ... see if the database was restarted and store the new startup ... > Oracle 10g Certified Professional ...
    (comp.databases.oracle.server)