๐ YugabyteDB ์ง์ญ ๋ถํ ํ ์ด๋ธ์์๋ง ๋ก์ปฌ ํํฐ์ ์ ์ก์ธ์ค
24540 ๋จ์ด distributedyugabyteddatabasesql
85338353-162a-4a62-bcb9-78fd58a6b500
์ ๊ทธ๊ณณ์ ์์์ง๋ง 1c888089-c4f2-4da4-ba61-59957b965bf8
๋ ์ง๊ตฌ์์ ์์ต๋๋ค.yugabyte=# select planet,id from customers
where id in ('1c888089-c4f2-4da4-ba61-59957b965bf8','85338353-162a-4a62-bcb9-78fd58a6b500');
planet | id
--------+--------------------------------------
earth | 1c888089-c4f2-4da4-ba61-59957b965bf8
mars | 85338353-162a-4a62-bcb9-78fd58a6b500
(2 rows)
์ค๋ณต ์ปค๋ฒ๋ง ์ธ๋ฑ์ค ๋๋ถ์ ์ด ์ฟผ๋ฆฌ๋ ๋ก์ปฌ ์ฝ๊ธฐ๋ก๋ง ๋ฌ์ฑ๋์์ต๋๋ค.
yugabyte=# explain analyze select planet,id from customers
where id in ('1c888089-c4f2-4da4-ba61-59957b965bf8','85338353-162a-4a62-bcb9-78fd58a6b500');
๋ค๋ฅธ ๋ฐฉ๋ฒ์ ๋ณด์ฌ์ฃผ๊ธฐ ์ํด ํด๋น ์์ธ์ ์ญ์ ํ๊ฒ ์ต๋๋ค.
drop index customers_moon_id_planet_earth;
drop index customers_mars_id_planet_earth;
drop index customers_earth_id_planet_moon;
drop index customers_mars_id_planet_moon;
drop index customers_earth_id_planet_mars;
drop index customers_moon_id_planet_mars;
์ด์ ๋์ผํ ์ฟผ๋ฆฌ๋ฅผ ์คํํ๋ฉด ๋ชจ๋ ์ง์ญ์์ ํํฐ์ ์ ์ฝ์ด์ผ ํฉ๋๋ค.
yugabyte=# explain analyze select planet,id from customers
where id in ('1c888089-c4f2-4da4-ba61-59957b965bf8','85338353-162a-4a62-bcb9-78fd58a6b500');
yugabyte=# explain analyze select planet,id from customers
yugabyte-# where id in ('1c888089-c4f2-4da4-ba61-59957b965bf8','85338353-162a-4a62-bcb9-78fd58a6b500');
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------------
Append (cost=0.00..46.65 rows=300 width=48) (actual time=1.798..5.347 rows=2 loops=1)
-> Index Scan using customers_earth_pkey on customers_earth (cost=0.00..14.65 rows=100 width=48) (actual time=1.798..1.800 rows=1 loops=1)
Index Cond: (id = ANY ('{1c888089-c4f2-4da4-ba61-59957b965bf8,85338353-162a-4a62-bcb9-78fd58a6b500}'::uuid[]))
-> Index Scan using customers_mars_pkey on customers_mars (cost=0.00..15.25 rows=100 width=48) (actual time=1.073..1.075 rows=1 loops=1)
Index Cond: (id = ANY ('{1c888089-c4f2-4da4-ba61-59957b965bf8,85338353-162a-4a62-bcb9-78fd58a6b500}'::uuid[]))
-> Index Scan using customers_moon_pkey on customers_moon (cost=0.00..15.25 rows=100 width=48) (actual time=2.469..2.469 rows=0 loops=1)
Index Cond: (id = ANY ('{1c888089-c4f2-4da4-ba61-59957b965bf8,85338353-162a-4a62-bcb9-78fd58a6b500}'::uuid[]))
Planning Time: 19.236 ms
Execution Time: 5.876 ms
Peak Memory Usage: 64 kB
(10 rows)
)
์ด์ ์ด์ ๊ฒ์๋ฌผ์์ ์ง์ญ์ ์๋ฉด ๋ชจ๋ SQL ์ฒ๋ฆฌ๊ฐ ๋ก์ปฌ์ด ๋๋๋ก ์ฐ๊ฒฐํ๋ ๊ฒ์ด ์ข์ต๋๋ค. ์ฌ๊ธฐ์ ๋ด ๋์์ ๊ณ ๊ฐ์ด ๋ก์ปฌ ํํฐ์ ์ ์๋์ง ํ์ธํ๋ ๊ฒ์ ๋๋ค. ๊ทธ๋ ์ง ์์ ๊ฒฝ์ฐ ์๊ฒฉ ์ฝ๊ธฐ๋ฅผ ์ํํ์ง ์์ง๋ง ๋ค๋ฅธ ์ง์ญ์ ์ฐ๊ฒฐํ์ฌ ์๋ํ ์ ์์ต๋๋ค.
yb_is_local_table
YugabyteDB์๋ ๋ก์ปฌ ํํฐ์ ์ผ๋ก๋ง ํํฐ๋งํ ์ ์๋ ํน์ ๊ธฐ๋ฅ์ด ์์ต๋๋ค.
yugabyte=# select * from customers
where id in ('1c888089-c4f2-4da4-ba61-59957b965bf8','85338353-162a-4a62-bcb9-78fd58a6b500')
and yb_is_local_table(tableoid);
id | planet | info
--------------------------------------+--------+------
85338353-162a-4a62-bcb9-78fd58a6b500 | mars | 42
(1 row)
์ด๊ฒ์ ํ์ง ๊ณ ๊ฐ ๋ง ๋ฐํํ์ต๋๋ค.
yugabyte=# explain analyze select * from customers
where id in ('1c888089-c4f2-4da4-ba61-59957b965bf8','85338353-162a-4a62-bcb9-78fd58a6b500')
and yb_is_local_table(tableoid);
QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------
Append (cost=0.00..15.65 rows=100 width=80) (actual time=1.715..1.719 rows=1 loops=1)
-> Index Scan using customers_mars_pkey on customers_mars (cost=0.00..15.15 rows=100 width=80) (actual time=1.715..1.718 rows=1 loops=1)
Index Cond: (id = ANY ('{1c888089-c4f2-4da4-ba61-59957b965bf8,85338353-162a-4a62-bcb9-78fd58a6b500}'::uuid[]))
Filter: yb_is_local_table(tableoid)
Planning Time: 0.338 ms
Execution Time: 1.792 ms
Peak Memory Usage: 32 kB
(7 rows)
์ด ๊ณ ๊ฐ์ ์ฒ๋ฆฌํ ๋ค์ ์ ํํ ๋์ผํ ์ฟผ๋ฆฌ๋ฅผ ์คํํ๋ฉด์ ๋ค๋ฅธ ๊ณณ์ ์ฐ๊ฒฐํ์ฌ ๋ค๋ฅธ ๊ณ ๊ฐ์ ์ฒ๋ฆฌํ ์ ์์ต๋๋ค.
๋ค์์ ์์ ๋๋ค.
yugabyte=# \c yugabyte yugabyte yb-tserver-2
You are now connected to database "yugabyte" as user "yugabyte".
yugabyte=# select * from customers
where id in ('1c888089-c4f2-4da4-ba61-59957b965bf8','85338353-162a-4a62-bcb9-78fd58a6b500')
and yb_is_local_table(tableoid);
id | planet | info
--------------------------------------+--------+------
85338353-162a-4a62-bcb9-78fd58a6b500 | mars | 42
(1 row)
yugabyte=# \c yugabyte yugabyte yb-tserver-1
You are now connected to database "yugabyte" as user "yugabyte" on host "yb-tserver-1" at port "5433".
yugabyte=# select * from customers
where id in ('1c888089-c4f2-4da4-ba61-59957b965bf8','85338353-162a-4a62-bcb9-78fd58a6b500')
and yb_is_local_table(tableoid);
id | planet | info
----+--------+------
(0 rows)
yugabyte=# \c yugabyte yugabyte yb-tserver-0
You are now connected to database "yugabyte" as user "yugabyte" on host "yb-tserver-0" at port "5433".
yugabyte=# select * from customers
where id in ('1c888089-c4f2-4da4-ba61-59957b965bf8','85338353-162a-4a62-bcb9-78fd58a6b500')
and yb_is_local_table(tableoid);
id | planet | info
--------------------------------------+--------+------
1c888089-c4f2-4da4-ba61-59957b965bf8 | earth | 42
(1 row)
๊ทธ๋์ ์ด๊ฒ์ ๋ค๋ฅธ ๋ฐฉ๋ฒ์ ๋๋ค. ์ผ๋ฐ์ ์ผ๋ก ์ง๋ฆฌ์ ์ผ๋ก ๋ถํ ๋ ๋ฐ์ดํฐ๋ฒ ์ด์ค์์๋ ํ ์ง์ญ์ ์ฐ๊ฒฐํ๊ณ ์์ ํฉ๋๋ค. ์ง์ญ์ ๋ชจ๋ฅธ๋ค๋ฉด ์ด์ ๊ฒ์๋ฌผ์์ ์ธ๋ฑ์ค๋ก ์ง๋๋ฅผ ์ ์งํ๋ ๋ฐฉ๋ฒ์ ์ค๋ช ํ์ต๋๋ค. ๊ทธ๋ฌ๋ ๊ต์ฐจ ์ง์ญ ์์ ๋๋ ๋ณด๊ณ ๊ฐ ์๋ ๊ฒฝ์ฐ ๊ฐ ์ง์ญ์ผ๋ก ์ด๋ํ์ฌ ์ง์ญ์ ์ฒ๋ฆฌ/๋ณด๊ณ ํ๋ ๊ฒ์ด ์ข์ต๋๋ค. ์ธ๋ฑ์ค๊ฐ ํ์ํ์ง ์์ง๋ง
yb_is_local_table(tableoid)
ํจ์๋ฅผ ์ฌ์ฉํฉ๋๋ค.
Reference
์ด ๋ฌธ์ ์ ๊ดํ์ฌ(๐ YugabyteDB ์ง์ญ ๋ถํ ํ ์ด๋ธ์์๋ง ๋ก์ปฌ ํํฐ์ ์ ์ก์ธ์ค), ์ฐ๋ฆฌ๋ ์ด๊ณณ์์ ๋ ๋ง์ ์๋ฃ๋ฅผ ๋ฐ๊ฒฌํ๊ณ ๋งํฌ๋ฅผ ํด๋ฆญํ์ฌ ๋ณด์๋ค https://dev.to/yugabyte/access-the-local-partition-only-in-yugabytedb-geo-partitioned-tables-1df6ํ ์คํธ๋ฅผ ์์ ๋กญ๊ฒ ๊ณต์ ํ๊ฑฐ๋ ๋ณต์ฌํ ์ ์์ต๋๋ค.ํ์ง๋ง ์ด ๋ฌธ์์ URL์ ์ฐธ์กฐ URL๋ก ๋จ๊ฒจ ๋์ญ์์ค.
์ฐ์ํ ๊ฐ๋ฐ์ ์ฝํ ์ธ ๋ฐ๊ฒฌ์ ์ ๋ (Collection and Share based on the CC Protocol.)
์ข์ ์นํ์ด์ง ์ฆ๊ฒจ์ฐพ๊ธฐ
๊ฐ๋ฐ์ ์ฐ์ ์ฌ์ดํธ ์์ง
๊ฐ๋ฐ์๊ฐ ์์์ผ ํ ํ์ ์ฌ์ดํธ 100์ ์ถ์ฒ ์ฐ๋ฆฌ๋ ๋น์ ์ ์ํด 100๊ฐ์ ์์ฃผ ์ฌ์ฉํ๋ ๊ฐ๋ฐ์ ํ์ต ์ฌ์ดํธ๋ฅผ ์ ๋ฆฌํ์ต๋๋ค