0

table A has billions of data and table B have very less amount of records. we are fetching union all of A and B using UNION ALL. when we do sort by on top of view query, it took a long time to fetch the records do u have any idea how we can improve the performance?

  • 3
    Don't do the `order by`. Ordering billions of rows takes time. – Gordon Linoff Dec 01 '17 at 12:26
  • There is no generic solution to this, but your situation may be improved if you tell us more about the data. What does the tables look like? What kind of data do they hold? Why do they have to be sorted like that? How often do they need to be sorted like that? Who or what updates the tables and when? There are often patterns in the data itself or in the way it is being added/updated that can be exploited for performance gains. – Ronnis Dec 01 '17 at 13:20
  • if don't specify the sort then hibernate pagination may come with duplicates data set. To avoid the that we are doing the sort. Here my problem is when I do individual query fetching in order by it is so fast. why union all + sort takes a long time to fetch data? – user3260053 Dec 01 '17 at 13:49

0 Answers0