Search code examples
jdbcsap-asesql-execution-plan

Sybase Query Plan too large lots of "child tables"


I have a simple Query:

DELETE FROM TABLE1 WHERE ID=1

This table is referred by at least 90 (X) other table :

ADD CONSTRAINT FK_TABLEX_TABLE1
FOREIGN KEY (ID)
REFERENCES "db"."TABLE1"(ID)

Looking at the plan for the given query, it's really large. We have DIRECT RI FILTER Operator (VA = 103) has 98 children. and then a bunch of SCAN Operator (VA = X) FROM TABLE TABLEX ...

The problem is that when we use batch deletion (JDBC) and reach immediately the procedure cache limit (which we did try to increase a lot, but the solution is not ok because children tables number is meant to increase).

However, my DELETE queries should only look into 5 tables for each different batch (I know that IDs XXX,YYY and ZZZ are referred by TABLEX, TABLEX+1, ... TABLEX+4). Is there a way to force the query plan to limit the scan to some tables ?

Modifying the data model is not really an option.

Sybase 15.0.3
JConnect3d 6.0.5

I did reduce the number of queries done in the batch and going from 1000 to 100 won't crash anymore. It's a solution but I would like to reduce the query plan, not the batch.


Solution

  • Finally we ended up having a batch size computed from the number of child tables.

    The more table the less update in the same batch.