èšäºãæžãå§ããã®ã¯éåžžã«é£ããã§ãã ã€ãŸããæåã®èšèãæãä»ãã®ã¯éåžžã«å°é£ã§ãã ç§ã¯äžåºŠã«ãã¹ãŠã®ããšã«ã€ããŠè©±ãããã§ã:)ãããããããã äžè²«æ§ããããŸãã
ãããããæè¿ãç§ã蚪ããHighload ++ 2008ãéå¬ãããŸããã
ç§ã¯ããã«èšããªããã°ãªããªã-ã€ãã³ãã¯æé«ã¯ã©ã¹ã§éå¬ãããå€ãã®ã¬ããŒããããããã¹ãŠãéåžžã«é¢çœãã£ãã
æãèšæ¶ã«æ®ããã¬ãŒã³ããŒã·ã§ã³ã®1ã€ã¯ãSkypeã®ããŒã¿ããŒã¹ãµãŒããŒã®ã€ã³ãã©ã¹ãã©ã¯ãã£ã«ã€ããŠã®Asya Oyaã«ããè¬æŒã§ããã è¬çŸ©ã§ã¯ããã®ãããªãµãŒããŒã®ããã©ãŒãã³ã¹ãå®çŸããããŸããŸãªæ段ã«çŠç¹ãåœãŠãŸããã
Askoã«ããã°ãå°çã®ãã¹ãŠã®äœæ°ãäžç¬ã§ã¹ã«ã€ãã«æ¥ç¶ãããå Žåã§ããSkypeããŒã¿ããŒã¹ã¯åç¶ããŸãã
家ã«çããšãããããã¹ãŠã©ã€ãã§è©ŠããŠã¿ããã£ãã®ã§ãã ä»ãã話ããŸãã ããã«äºçŽããŸãããã¹ãã®ããŒã¿ããŒã¹æ§é ã¯ãéçºè
èªèº«ã®Webãµã€ãã®äŸããåããããã®ã§ãããå®éã®èªã¿èŸŒã¿ãšã¯é¢ä¿ãããŸããã
ãã®èšäºã§ã¯ãããŒããã©ã³ã·ã³ã°ãæ¢ã«ãããã«ãªãããŒã¹ãäœäžããåŸã«è¡ãå¿
èŠãããããšã説æããŸãããããã¯å®å
šã«çå®ã§ã¯ãããŸããã ãã®èšäºã®å©ããåããŠãç§ã¯åå¿è
ãšçµéšã®æµ
ãéçºè
ãæºåãããšåæã«ãã·ã¹ãã ãèšèšãããšãã«ãµãŒããŒéã®è² è·åæ£ã®å¯èœæ§ãæäŸããå¿
èŠããããšããäºå®ã«ã€ããŠèããããããšæããŸãã ãããŠãããã¯ã圌ããããã»ã©å€ãã®ããšãæžããããæããããããææå°æ©ã®æé©åããšã¯ã¿ãªãããŸããã
UPDïŒ descentspb habrayuzerãèšäºã§æ£ããè¿°ã¹ãŠããããã«ãè¿·æãªãšã©ãŒããããŸãã äžæ³šæã®çµæããããã·ãšã¯ã©ã€ã¢ã³ãã®éã«PgBouncerãã€ã³ã¹ããŒã«ããå¿
èŠããããšèããŸããã ããããå€æããããã«ãPgBouncerã®å©ããåããŠè§£æ±ºããåé¡ã¯ããã®ããã«ã€ã³ã¹ããŒã«ããŠã解決ãããŸããã ããŒããšãããã·ã®éã«ããŠã³ãµãŒãã€ã³ã¹ããŒã«ããããšããå§ãããŸãã ããã«ãããã¯ãŸãã«PL / ProxyãŠã§ããµã€ãã®å
¬åŒããã¥ã¢ã«ã§æšå¥šãããŠããããšã§ãã
ãããã«ãããå³ã«ç€ºãããŠããããã«PgBouncerã䜿çšãããšãããã©ãŒãã³ã¹ãåäžããŸãã ïŒãããã·ã®ã¢ã³ããŒãïŒã1.誰ã®ããã§ããïŒ
ãã®ãããéçºè
ã§ããã倧ãããŠéåžžã«è² è·ã®å€§ãããã®ãäœæãããšãé
ããæ©ãããããŒã¿ããŒã¹ãè² è·ã«èããããªããšããäºå®ã«æ°ä»ãã§ãããã å€ãã®èŠæ±ããããéã¯åã«ãããã«å¯ŸåŠããããšãã§ããŸããã
ãã®åé¡ã解決ããæ¹æ³ã¯äœåºŠãè°è«ãããŠããŸããããæãå¹æçã ãšæããããã®ã®ãªã¹ãã®ã¿ãæäŸããŸãã
-ã³ãŒããæé©åããŸãã
-ãµãŒããŒã®èœåãåäžãããŸãã
-ãã£ãã·ã¥ïŒmemcacheã«é¢ããèšäºãã¿ã°ã§æ€çŽ¢ããŸãïŒã
-ãµãŒããŒéã§è² è·ãåæ£ããŸãã
æåŸã®ç¹ã«ã€ããŠèª¬æããŸãããã
2.äœãããïŒ
ãã®ãããã³ãŒãã¯æé©åããããµãŒããŒã¯ã©ãããã涌ãããªããŸã;ããŒã¿ããŒã¹å
šäœããã£ãã·ã¥å
ã«ãããŸãããããã§ãåäžã®ãªã¯ãšã¹ãã§ã¯ã©ãã·ã¥ããŸãã æ°Žå¹³æ¹åã®ã¹ã±ãŒãªã³ã°ãè¡ããšãã§ãã
ãããç§ã¯ãŸã PostgreSQLã«é¢ãããã®èšäºã«ã€ããŠèšåããŠããŸããã ãŸã MySQLã䜿çšããŠããŸããïŒ ãã®åŸãç§ãã¡ã¯ããªãã«è¡ããŸã:)
ç§ã®è¬èãªæèŠã§ã¯ããããžã§ã¯ããæ¬åœã«æ·±å»ãªå ŽåãããŒã¹ã¯MySQLãããå°ãæ·±å»ã«ãªãã¯ãã§ãã ããã«ãPostgresã«ã¯ã¹ã±ãŒãªã³ã°ã®ããã®ãã°ãããããŒã«ããããŸãã ïŒãã¶ãMySQLçšã®ãã®ãããã®ã§ããããïŒç§ã¯å¿çèšäºãåŸ
ã£ãŠããŸã:)ïŒã
3.ãããŠã圌ãã¯äœãé£ã¹ãŸããïŒ
PL /ãããã·ã¯ãPostgreSQLããŒã¿ããŒã¹ãµãŒããŒäžã®é¢æ°ããªã¢ãŒãã§åŒã³åºããããããŒã¿ãåå²ãããããããã®èšèªã§ãã
äœæ¥ã®ã¹ããŒã ã¯åçã«ç€ºãããŠããŸãã PgBouncerã«ã€ããŠã¯åŸè¿°ããŸãã
éåžžãã¢ããªã±ãŒã·ã§ã³ã¯ããŒã¿ããŒã¹ãç
§äŒããã ãã§ãã ãã®å Žåãã¢ããªã±ãŒã·ã§ã³ã¯ããŒã¿ããŒã¹ã«å¯ŸããŠéåžžã®ã¯ãšãªãå®è¡ããŸãã çŽç²ãªSQLã³ãŒããåŒã³åºãã®ã§ã¯ãªããäºåã«äœæãããé¢æ°ãåŒã³åºããŸãã
次ã«ãããŒã¿ããŒã¹ã¯ãå¿
èŠãªããŒã¿ãã©ã®ããŒãã«ããããå€æããŸãã
ãããŠãèŠæ±ãç®çã®ãµãŒããŒã«ãªãã€ã¬ã¯ãããŸãã
èŠæ±ãå®è¡ãããã¡ã€ã³ãµãŒããŒã«è¿ãããåŸãããŒã¿ãã¢ããªã±ãŒã·ã§ã³ã«è¿ãããŸãã
ãã¹ãŠãããŸãããããã«èŠããŸããããªã¯ãšã¹ãã®æ°ãå€ããšãPL / Proxyã¯
ããŒããžã®æ¥ç¶æ°ãããã«ãããæ°ããPostgresïŒãã©ãŒã¯ïŒããã»ã¹ãäœæãããŸãããããã¯ããã©ãŒãã³ã¹ã«ããŸã圱é¿ããŸããã ãã®åé¡ã解決ããã«ã¯ãPgBouncerãå¿
èŠã§ãã
PgBouncerã¯... mm ...ä¿®æ£ã§ããªãããã«èšãæ¹æ³...æ¥ç¶ãã«ããã¬ã¯ãµã éåžžã®Postgresããã»ã¹ã®ããã«èŠããŸãããå
éšã§ã¯ãªã¯ãšã¹ããã¥ãŒã管çããŠããããããµãŒããŒã®é床ãåäžãããããšãã§ããŸãã PgBouncerãåä¿¡ããæ°åã®ãªã¯ãšã¹ãã®ãã¡ãããŒã¿ããŒã¹ã«å°éããã®ã¯æ°ããŒã¹ã ãã§ãã
ãã®ãã°ãããããŒã«ã䜿çšããããšã®ããŒãã¹ãè©äŸ¡ããã«ã¯ãPgBouncerããªã³ã«ããååŸã«2ã€ã®ãµã€ãã«ããŒã¿ããŒã¹ãµãŒããŒãããŒãããã¹ã±ãžã¥ãŒã«ãèŠãŠãã ããã åçã¯ãã³ã©ã€ã»ãµã¢ã¯ããããããã©ãŒãã³ã¹ã»ãã¹ãã°ã¬ã¹ãã®ãã¬ãŒã³ããŒã·ã§ã³ããåãããŠããŸãã
4.æããããã¬ã³ãããŒã«ããã ãã
4.1 PgBouncerã®ã€ã³ã¹ããŒã«
ã€ã³ã¹ããŒã«ããã»ã¹ã¯ãŸã£ããå
ã®ãã®ã§ã¯ãããŸããïŒ
ããã±ãŒãžãããŠã³ããŒãããŸãïŒå·çæç¹ã§ã¯ãææ°ããŒãžã§ã³ã¯1.2.3ã§ããïŒ
pgfoundry.org/frs/?group_id=1000258é梱ïŒ
#tar -xzvf pgbouncer-1.2.3.tgz
:
#cd pgbouncer-1.2.3
#./configure
#make
#make install
æ§æãã¡ã€ã«ãäœæããŸãã
/etc/pgbouncer/pgbouncer.ini
[databases]
testdb = host=localhost port=5432 dbname=testdb
[pgbouncer]
listen_port = 6543
listen_addr = 127.0.0.1
auth_type = md5
auth_file = users.txt
logfile = /var/log/pgbouncer.log
pidfile = /var/run/pgbouncer/pgbouncer.pid
pool_mode = statement # PL/Proxy
admin_users = root
èªèšŒãã¡ã€ã«ãäœæããŸãã
/etc/pgbouncer/users.txt
"testdb_user" "testdb_user_password"
以äžãéå§ããŸãã
/usr/local/bin/pgbouncer -d /etc/pgbouncer/pgbouncer.ini -u postgres
-dã¹ã€ããã¯ããŒã¢ã³ã¢ãŒãã§å®è¡ããå¿
èŠãããããšã瀺ãã-uã¹ã€ããã¯pgbouncerããã»ã¹ãèµ·åãããŠãŒã¶ãŒã瀺ããŸãã
gentooãŠãŒã¶ãŒã®å Žåãã¹ã¿ãŒãã¢ããã¹ã¯ãªãããšãã圢ã§ã®é©ãã¯æ¬¡ã®ãšããã§ãã
/etc/init.d/pgbouncer
#!/sbin/runscript
depend() {
need postgresql
use pgsql
}
start() {
ebegin "Starting Pgbouncer"
start-stop-daemon --start --background --exec /usr/local/bin/pgbouncer --chdir /etc/pgbouncer/ -- -d pgbouncer.ini -u postgres
eend $? "Failed to start Pgbouncer"
}
stop() {
ebegin "Stopping Pgbouncer"
start-stop-daemon --pidfile /var/run/pgbouncer/pgbouncer.pid --stop
eend $? "Failed to stop Pgbouncer"
}
ããã§ãã¢ããªã±ãŒã·ã§ã³ã®DSNãšããŠãããŒã¿ããŒã¹ã«æ¥ç¶ããããŒãã5432ãã6543ã«å€æŽããã ãã§ãååŸã®ãµãŒããŒè² è·ã®æ¯èŒãéå§ã§ããŸãã
4.2 Pl / Proxyã®ã€ã³ã¹ããŒã«
ãã®å®éšã«ã¯ã3ã€ã®PostgresãµãŒããŒãå¿
èŠã§ãã
ãã®ãã¡ã®1ã€ã¯ããããã·ãšåŒã³ãŸããããä»ã®2ã€ã«ãªã¯ãšã¹ãããããã·ããŸãã
ããããnode1ããã³node2ãšåŒã³ãŸãããã
pl /ãããã·ãæ£ããåäœãããã«ã¯ã2ã®ã¹ãä¹ã«çããããŒãæ°ã䜿çšããããšããå§ãããŸãã
ãã§ã«Postgresãã€ã³ã¹ããŒã«ãããŠãããšæããŸãã
ãããã·ãµãŒããŒã«PL /ãããã·ãã€ã³ã¹ããŒã«ããŸãã
pl /ãããã·ã®ææ°ããŒãžã§ã³ãããŠã³ããŒãïŒ
pgfoundry.org/frs/?group_id=1000207ãã€ãã®ããã«ïŒ
ïŒã/èšå®
#make
#make install
ããã¯ãPostgresèªäœãåèµ·åããå¿
èŠãããå Žæã§ãã
ãããŠä»ã楜ãã¿ãå§ãŸããŸãã
ãã¹ãã®ããã«ãåããŒãã§æ°ããproxytestããŒã¿ããŒã¹ãäœæããŸãã
CREATE DATABASE proxytest
WITH OWNER = postgres
ENCODING = 'UTF8' ;
ãã®ããŒã¹å
ã§ãplproxyãšããã¹ããŒããäœæããŸãã ãã®é
ç®ã¯å
¬åŒã®æ瀺ã«ã¯ãããŸããã§ããããäœããã®çç±ã§ãåŒã³åºããããã¹ãŠã®é¢æ°ããã®æ¹æ³ã§åŒã³åºãããããšããŸããïŒplproxy.functionameïŒïŒã
CREATE SCHEMA plproxy
AUTHORIZATION postgres;
GRANT ALL ON SCHEMA plproxy TO postgres;
GRANT ALL ON SCHEMA plproxy TO public ;
ãããŠãããã«1ã€ã®ãã¬ãŒããè¿œå ããŸãïŒ
CREATE TABLE plproxy.users
(
user_id bigint NOT NULL DEFAULT nextval( 'plproxy.user_id_seq' ::regclass),
username character varying (255),
email character varying (255),
CONSTRAINT users_pkey PRIMARY KEY (user_id)
)
WITH (OIDS= FALSE );
ALTER TABLE plproxy.users OWNER TO postgres;
次ã«ããããã®ããŒãã«ã«ããŒã¿ãè¿œå ããé¢æ°ãäœæããŸãã
CREATE OR REPLACE FUNCTION plproxy.insert_user(i_username text, i_emailaddress text)
RETURNS integer AS
$BODY$
INSERT INTO plproxy.users (username, email) VALUES ($1,$2);
SELECT 1;
$BODY$
LANGUAGE 'sql' VOLATILE;
ALTER FUNCTION plproxy.insert_user(text, text) OWNER TO postgres;
ããŒããçµäºããŸããã ãµãŒããŒãã»ããã¢ããããŸãããã
ãã¹ãŠã®ããŒããšåæ§ã«ãããŒã¿ããŒã¹ã¯ã¡ã€ã³ãµãŒããŒïŒãããã·ïŒäžã«ååšããå¿
èŠããããŸãã
CREATE DATABASE proxytest
WITH OWNER = postgres
ENCODING = 'UTF8' ;
察å¿ããã¹ããŒãïŒ
CREATE SCHEMA plproxy
AUTHORIZATION postgres;
GRANT ALL ON SCHEMA plproxy TO postgres;
GRANT ALL ON SCHEMA plproxy TO public ;
次ã«ããã®ããŒã¿ããŒã¹ãpl / proxyã䜿çšããŠç®¡çãããŠããããšããµãŒããŒã«äŒããå¿
èŠããããŸãã
CREATE OR REPLACE FUNCTION plproxy.plproxy_call_handler()
RETURNS language_handler AS
'$libdir/plproxy' , 'plproxy_call_handler'
LANGUAGE 'c' VOLATILE
COST 1;
ALTER FUNCTION plproxy.plproxy_call_handler() OWNER TO postgres;
-- language
CREATE LANGUAGE plproxy HANDLER plproxy_call_handler;
ãŸãããµãŒããŒãã©ãã«ã©ã®ããŒããæã£ãŠããããç¥ãã«ã¯ãpl / proxyãäœæ¥ã§äœ¿çšãã3ã€ã®ãµãŒãã¹é¢æ°ãäœæããå¿
èŠããããŸãã
CREATE OR REPLACE FUNCTION plproxy.get_cluster_config( IN cluster_name text, OUT " key " text, OUT val text)
RETURNS SETOF record AS
$BODY$
BEGIN
-- lets use same config for all clusters
key := 'connection_lifetime' ;
val := 30*60; -- 30m
RETURN NEXT ;
RETURN ;
END ;
$BODY$
LANGUAGE 'plpgsql' VOLATILE
COST 100
ROWS 1000;
ALTER FUNCTION plproxy.get_cluster_config(text) OWNER TO postgres;
ã³ãŒããä¿®æ£ããå¿
èŠãããéèŠãªé¢æ°ã ãã®äžã§ãDSNããŒããæå®ããå¿
èŠããããŸãã
REATE OR REPLACE FUNCTION plproxy.get_cluster_partitions(cluster_name text)
RETURNS SETOF text AS
$BODY$
BEGIN
IF cluster_name = 'clustertest' THEN
RETURN NEXT 'dbname=proxytest host=node1 user=postgres' ;
RETURN NEXT 'dbname=proxytest host=node2 user=postgres' ;
RETURN ;
END IF ;
RAISE EXCEPTION 'Unknown cluster' ;
END ;
$BODY$
LANGUAGE 'plpgsql' VOLATILE
COST 100
ROWS 1000;
ALTER FUNCTION plproxy.get_cluster_partitions(text) OWNER TO postgres;
ãããŠæåŸã®1ã€ïŒ
CREATE OR REPLACE FUNCTION plproxy.get_cluster_version(cluster_name text)
RETURNS integer AS
$BODY$
BEGIN
IF cluster_name = 'clustertest' THEN
RETURN 1;
END IF ;
RAISE EXCEPTION 'Unknown cluster' ;
END ;
$BODY$
LANGUAGE 'plpgsql' VOLATILE
COST 100;
ALTER FUNCTION plproxy.get_cluster_version(text) OWNER TO postgres;
å®éãã¢ããªã±ãŒã·ã§ã³ã§çŽæ¥åŒã³åºãããæãéèŠãªé¢æ°ã¯æ¬¡ã®ãšããã§ãã
CREATE OR REPLACE FUNCTION plproxy.insert_user(i_username text, i_emailaddress text)
RETURNS integer AS
$BODY$
CLUSTER 'clustertest' ;
RUN ON hashtext(i_username);
$BODY$
LANGUAGE 'plproxy' VOLATILE
COST 100;
ALTER FUNCTION plproxy.insert_user(text, text) OWNER TO postgres;
é¢æ°ã³ãŒãã«é¢ãã質åã¯ã³ã¡ã³ãã«å«ãŸããŠããŸãããç§ã¯Postgresã®ç¬¬äžäººè
ã§ã¯ãªããåãªãåŠçã§ããããšãå¿ã«çããŠãããŠãã ããã
ãããŠä»ãç§ãã¡ã¯ãã¹ãããŠããŸãïŒ :)
ããŒã6543ã§ãããã·ãµãŒããŒã«æ¥ç¶ããŸãïŒããã«PgBouncerã䜿çšããŸãïŒã
ãããŠãããŒã¿ããŒã¹ã«ããŒã¿ãå
¥åããŸãã
SELECT insert_user( 'Sven' , 'sven@somewhere.com' );
SELECT insert_user( 'Marko' , 'marko@somewhere.com' );
SELECT insert_user( 'Steve' , 'steve@somewhere.com' );
ããã§ãåããŒãã«æ¥ç¶ã§ãããã¹ãŠãæ£ãããšã©ãŒãªãå®è¡ããå Žåãæåã®2ã€ã®ãšã³ããªã¯node1ã«ã3çªç®ã®ãšã³ããªã¯node2ã«ãããŸãã
ããŒã¿ãæœåºããããšããŠããŸãã
ãããè¡ãã«ã¯ãæ°ãããµãŒããŒé¢æ°ãäœæããŸãã
CREATE OR REPLACE FUNCTION plproxy.get_user_email(i_username text)
RETURNS SETOF text AS
$BODY$
CLUSTER 'clustertest' ;
RUN ON hashtext(i_username) ;
SELECT email FROM plproxy.users WHERE username = i_username;
$BODY$
LANGUAGE 'plproxy' VOLATILE
COST 100
ROWS 1000;
ALTER FUNCTION plproxy.get_user_email(text) OWNER TO postgres;
ãããŠããããåŒã³åºããŠã¿ãŠãã ããïŒ
select plproxy.get_user_email( 'Steve' );
Vopschemããã¹ãŠãç§ã®ããã«ããŸããã£ãã
5.ãã€ãŠãããªã«é ãæªãã®ã¯ãªãã§ããïŒ
ãã¹ãäŸã§ãããããã«ãpl / proxyã§è€éãªããšã¯ãããŸããã ãããããã®è¡ãèªãããšãã§ãã人ã¯èª°ã§ããå®ç掻ã§ã¯ãã¹ãŠãããã»ã©åçŽã§ã¯ãªãããšããã§ã«èªèããŠãããšæããŸãã
16åã®ããŒãããããšããŸãã äœããã®æ¹æ³ã§æ©èœã³ãŒããåæããå¿
èŠããããŸãã ãããããšã©ãŒãå¿ã³èŸŒãã å Žåã¯ã©ãããã°ããã§ãã-ãã°ããä¿®æ£ããæ¹æ³ã¯ïŒ
ãã®è³ªåã¯äŒè°ã§ãå°ããããAskoã¯é©åãªè³éã¯ãã§ã«Skypeèªäœã«å®è£
ãããŠãããããªãŒãã³ãœãŒã¹ã³ãã¥ããã£ã§æ³å»·ã«æã¡èŸŒãã«ã¯ãŸã æºåãã§ããŠããªããšçããã
ãã®çš®ã®ã·ã¹ãã ãéçºãããšãã«ç¥ãçŠæ¢ãã2çªç®ã®åé¡ã¯ãã¯ã©ã¹ã¿ãŒã«å¥ã®ããŒããè¿œå ããããšãã«ããŒã¿ãåé
åžããåé¡ã§ãã
ãã¹ãŠã®ãµãŒããŒãäºåã«æºåããããŒã¿ãå
¥åããŠãããget_cluster_partitionsé¢æ°ã³ãŒããäžåºŠå€æŽããŠããã®å€§èŠæš¡ãªæäœãæ
éã«èšç»ããå¿
èŠããããŸãã
6.è¿œå è³æ
Skypeéçºè
ãµã€ãã®
PlProxyããã³
PgBouncerãããžã§ã¯ã ã
Highload ++ã«é¢ããAskoãã¬ãŒã³ããŒã·ã§ã³ããã©ãŒãã³ã¹Postgres Nikolay SamokhvalovïŒPostgresmenïŒ
7.äžå¯§ãªããŒãã¹
èšäºãå
¬éããåŸã1ã€ã®ãšã©ãŒãš1ã€ã®æ¬ é¥ãèŠã€ãããŸããã
ãã§ã«æžãããèšäºãç·šéããã®ã¯é£ãããããããã§èª¬æããŸãã
1ïŒããŒãã«ã§user_id_seqãšããã·ãŒã±ã³ã¹ã䜿çšããŸãã ãã ãããã®ããã®SQLã³ãŒãã¯ã©ãã«ããããŸããã ãããã£ãŠã誰ããã³ãŒããåçŽã«ã³ããŒïŒããŒã¹ãããŠããäœãèµ·ãããŸããã ä¿®æ£æžã¿ïŒ
CREATE SEQUENCE plproxy.user_id_seq
INCREMENT 1
MINVALUE 0
MAXVALUE 9223372036854775807
START 1
CACHE 1;
ALTER TABLE plproxy.user_id_seq OWNER TO postgres;
2ïŒããŒã¿ããŒã¹ã«ããŒã¿ãæ¿å
¥ãããšãuser_idãã£ãŒã«ãã®ã·ãŒã±ã³ã¹ãçæãããŸãã ãã ãããããã®ã·ãŒã±ã³ã¹ã¯2ã€ãããŸãã ãããŠããããããç¬èªã®ããŒãã§åäœããŸãã ããã«ããã2人ã®ç°ãªããŠãŒã¶ãŒãåãuser_idãæã€ããšã«ãªããŸãã
ãããã£ãŠãæ°ããuser_idãããŒãã§ã¯ãªããããã·ãµãŒããŒã«ããã·ãŒã±ã³ã¹ããååŸãããããã«ãinsert_useré¢æ°ãä¿®æ£ããå¿
èŠããããŸãã ããã«ãããuser_idãã£ãŒã«ãã®éè€ãåé¿ã§ããŸãã
ZYïŒ
ãœãŒã¹ã³ãŒãHighliterã§ãã¹ãŠã®SQLã³ãŒãã匷調衚瀺ãããŸã