Mycat 分頁查詢過程及注意事項 坑點

2021-10-10 14:47:25 字數 587 閱讀 3660

原始sql:select * from table_name where type='***' order by create_time limit 10000,1000;

直接在mysql中執行:select * from table_name where type='***' order by create_time limit 10000,1000;

通過mycat執行:select * from table_name where type='***' order by create_timelimit 0,11000;#在mysql中真實執行sql

在分表的情況下,mycat對原始sql進行了改寫,分別到各個例項中執行,然後再對結果進行聚合,排序,返回結果。

坑點

在分表的情況下,且limit 的開始位置特別大的時候,將需要查詢大量的資料,並將各個分表的結果集返回到mycat中,然後在mycat中進行合併和排序,再返回結果。

結果集特別大的情況會查詢很慢,且容易導致mycat oom.

建議:不要用mycat進行大批量的資料分頁查詢;通過條件過濾,減小分頁前資料量大小;

oracle 儲存過程的基本語法 及注意事項

1.基本結構 create or replace procedure 儲存過程名字 param1 in type,param2 out type as變數1 integer 0 變數2 型別 值範圍 begin select count into 變數1 from 表1 where 列名 param...

oracle 儲存過程的基本語法 及注意事項

oracle 儲存過程的基本語法 及注意事項 oracle 儲存過程的基本語法 1.基本結構 create or replace procedure 儲存過程名字 引數1 in number,引數2 in number is 變數1 integer 0 變數2 date begin end 儲存過程...

oracle 儲存過程的基本語法 及注意事項

oracle 儲存過程的基本語法 1.基本結構 create or replace procedure 儲存過程名字 引數1 in number,引數2 in number is 變數1 integer 0 變數2 date begin end 儲存過程名字 2.select into statem...