Basically I'm dealing with very huge system with tables having 4crore + records. I have a table in which I face deadlock situation between a select statement and an insert statement. (This particular table doesn't have much records, usually <5000 records).
The code piece looks like this.(Obviously I've morphed columns and column names due to confidentiality issues).
set rowcount 1 --I want only one row to be fetched
select id, description from tQueue1 (1) --Fetch first record using index 1
/*Actually I've verified, this is the most optimal way to select the first row of the table. Basically the table is acting as a queue from which I'll be processing records one by one. Simulataneously as I process the data, new and new records keep getting inserted into the Queue*/
Now this select I specified up there is deadlocking with an insert into the same table.
I'm using 2 Stored Procedures. One for selecting and one for inserting. There are a number of c++ threads which control the firing of these SPs. That means, at a time multiple inserts are permitted.
The indexes are in place. No table scan is involved, yet again I'm getting Deadlocks.
The deadlock is occuring at the rate of 4-6 out of 15000 records. But everyday, I'll be processing atleast 1,00,000 rows. This is eating my brains out.
Does anyone here knows advanced Performance tuning in Sybase? Help in any form is appreciated.


