What if the paging speed of spring data jpa local query is slow?

problem description

the paging speed of spring data jpa local query is very slow, so it should be

that all entries are found and then paged.

the environmental background of the problems and what methods you have tried

related codes

/ / Please paste the code text below (do not replace the code with pictures)
@ Query (nativeQuery = true,

        value = "select * from anime a " +
        "left join anime_user au on (a.id = au.anime_id) and au.user_id = ?1 " +
        "order by ?-sharp{-sharppageable}",
        countQuery = "select count(*) from anime")
Page<Anime> getAnimeRankList(long id, Pageable pageable);

what result do you expect? What is the error message actually seen?

the same logic is used in mybatis and pagehelper will quickly get the result. I don"t know if jpa has a good solution

.
Dec.21,2021
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3aa9c-2c236.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3aa9c-2c236.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?