Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

problem in query execution

$
0
0
Hi,

I am facing strange problem when i am executing a proc to fetch records.
when i am retrieving 1 million records from table which has 5 million records it doesnt work properly
However iIf the same is executed to fetch 300,000 records all is well.
The records in table are stored in the following format

RefNo OrderNO nTranSerialNo
1    1    3       
1    2    3       
2    3    3       
2    4    3       
3    5    6       
3    6    6       

Total records are 5 million.

I am using CTE to store data in following format in a temp table

Table A
Ref no    ORderNo1 OrdernO2
1    1      2     
2    3      4     
3    5      6     

My final Select statment is


Select bb.nOrderNo, bb.nTokenNo, cc.nTokenNo cc.nOrderNo, bb.Symbol, bb.Quantity, bb.Type, cc.Symbol,cc.Quantity,cc.Type,
dd.Expiry, ee.Expiry, dd.Series, ee.Series, dd.Time, ee.Time
From A aa
Inner Join B bb
on a.OrderNo1 = bb.nOrderNo
Inner Join c cc
On a.OrderNo2 = cc.nOrderNo
Inner Join D dd
on bb.nTokenNo = dd.nTokenNO
Inner Join E ee
on cc.nToken   = ee.nTokenNo

When i am retrieving 1 million records some of the above column gets displayed blank. The blank display is random on any column and any record.
However if i am retreiving around 300,000 recrods all the values are correctly displayed.

Then i removed CTE and got the data as displayed in Table A using other format.
And i modified the above join too

Inner Join B bb
on a.OrderNo1 = bb.nOrderNo
and aa.RefNo = bb.nReferenceNo
Inner Join c cc
On a.OrderNo2 = cc.nOrderNo
And aa.RefNo = cc.nReferenceNo
And bb.nRefernceNo = cc.nReferenceNo
Inner Join D dd
on bb.nTokenNo = dd.nTokenNO
Inner Join E ee
on cc.nToken   = ee.nTokenNo

which finally displayed all the records correctly when retreiving 300,000 records.

Please note nOrderNo is unique accross the table and B and C are the same table.

Any clue

Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>