A replication table is a special type of table in OceanBase Database. A replication table can read the latest data modifications from any healthy replica. If you do not frequently write data and are more concerned about the operation latency and load balancing, a replication table is a good choice. For more information about replication tables, see Create a table in OceanBase Database documentation.
Example
Execute the following statement to create a replication table:
obclient [test]> CREATE TABLE TEST.DUP(C1 INT) DUPLICATE_SCOPE = 'cluster';Provide the partitioning key value in the SQL statement to be executed.
obclient [test]> SELECT * FROM TEST.DUP WHERE C1=123\GRun the EXPLAIN ROUTE command to view the routing process in ODP.
obclient [test]> EXPLAIN ROUTE SELECT * FROM test.dup WHERE C1=123\GThe following return result shows that ODP performs routing based on the DUP_REPLICA_FIRST routing strategy.
... > ROUTE_POLICY [INFO] Strong read duplicated table. Ignore proxy route policy and session route policy Route Plan ----------------- > SQL_PARSE:{cmd:"COM_QUERY", table:"dup"} > ROUTE_INFO:{route_info_type:"USE_PARTITION_LOCATION_LOOKUP"} > LOCATION_CACHE_LOOKUP:{mode:"oceanbase"} > TABLE_ENTRY_LOOKUP_START:{} > FETCH_TABLE_RELATED_DATA:{table_entry:"not partition table or part info no exists"} > TABLE_ENTRY_LOOKUP_DONE:{table:"dup", table_id:500685, table_type:"USER TABLE", has_dup_replica:true} > ROUTE_POLICY:{replica:"10.10.10.2:50110", idc_type:"SAME_IDC", zone_type:"ReadWrite", role:"FOLLOWER", type:"FULL", is_dup_replica:true, is_partition_server:true, chosen_route_type:"ROUTE_TYPE_DUP_PARTITION_UNMERGE_LOCAL", route_policy:"DUP_REPLICA_FIRST", trans_consistency:"STRONG", session_consistency:"STRONG", proxy_idc_name:"zue"} > CONGESTION_CONTROL:{svr_addr:"10.10.10.2:50110"}