Help me optimize the below sql,running for many many hours Database : sybase select too.toID,too.toName,frm.fromID,frm.fromName<br> from entityClientTempTable frm, entityClientTempTable too where frm.fromServerId = too.toServerId and frm.fromID < too.toID and lower(substring(frm.fromName, 0, CHARINDEX(''------'',frm.fromName))) like lower(too.toName)) Number of records in entityClientTempTable : half a million approx asked 15 Feb '18, 08:36 rohanit05 |
Please explain WHAT you are trying to accomplish.
Besides the obvious syntax errors, the biggest challenge MIGHT be the cartesion product (every row in entityClientTempTable is joined with every row in entityClientTempTable, so the candidate result set has 2x the number of rows).
Here's what your (fixed) code looks like when executed...