none
Order of DataRows queried using the DataTable.Select Method RRS feed

  • Question

  • Good day,

    I am currently using .NET framework 3.5 API to access data in SQL Server (2014) Database.

    Understand that in the API documentation for DataTable.Select Method (link below), there is a remark that warns users to specify the sort criteria argument, to ensure the proper sort order in the query results.

    https://docs.microsoft.com/en-us/dotnet/api/system.data.datatable.select?view=netframework-3.5

    1. From my observation, when the amount of data in the database is small, even when the sort criteria argument is not specified, the query results will always correspond to the database order (id). However, as the amount of DataRows in the DataTables grow, it comes to a "breaking point" where the order of query results starts to deviate from the database order. I am curious about why such a behavior occurs? Is this intended to optimize the query speed?

    2. Are there any indicators or warning signs I can look out for before this "breaking point" is reached? For example, is it dependent on the number of rows in a DataTable, or the filesize of the entire Database?

    Please help.

    Thanks,
    ZY

    Wednesday, April 10, 2019 8:58 AM

All replies

  • Hi ZY Chua,

    Thank you for posting here.

    >>1.I am curious about why such a behavior occurs? Is this intended to optimize the query speed?

    As I know, it would not come to a "breaking point". Could you provide the code which could reproduce the error for me to test?

    If you want to speed up, you could use another way. Please refer to the link below.

    https://stackoverflow.com/questions/3298167/datatable-select-and-performance-issue-in-c-sharp

    >>2. Are there any indicators or warning signs I can look out for before this "breaking point" is reached? For example, is it dependent on the number of rows in a DataTable, or the filesize of the entire Database?

    I could not make sure what cause the "braking point". There is no announcement of Microsoft to certify it.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Thursday, April 11, 2019 7:00 AM
    Moderator