$ cat /tmp/sites.sql
CREATE TABLE sites(
site_id bigint,
name varchar(128),
primary key(site_id)
);
$ cat /tmp/sites.vschema
{
"myks": {
"sharded": true,
"vindexes": {
"hash": {
"type": "hash"
}
},
"tables": {
"sites": {
"column_vindexes": [
{
"column": "site_id",
"name": "hash"
}
]
}
}
}
}
$ vtexplain -shards 32 -vschema-file /tmp/sites.vschema -schema-file /tmp/sites.sql -replication-mode "ROW" -output-mode text -sql "SELECT * FROM sites where site_id=100"
ERROR: logging before flag.Parse: E0831 19:26:03.615224 8558 syslogger.go:149] can't connect to syslog
----------------------------------------------------------------------
SELECT * FROM sites where site_id=100
1 myks/80-88: select * from sites where site_id = 100 limit 10001
----------------------------------------------------------------------
$ vtexplain -shards 32 -vschema-file /tmp/sites.vschema -schema-file /tmp/sites.sql -replication-mode "ROW" -output-mode text -sql "INSERT INTO sites (site_id) values (1000)"
ERROR: logging before flag.Parse: E0831 19:27:43.682951 8568 syslogger.go:149] can't connect to syslog
----------------------------------------------------------------------
INSERT INTO sites (site_id) values (1000)
1 myks/18-20: insert into sites(site_id) values (1000)
----------------------------------------------------------------------
$ vtexplain -shards 32 -vschema-file /tmp/sites.vschema -schema-file /tmp/sites.sql -replication-mode "ROW" -output-mode text -sql "INSERT INTO sites (site_id) values (1000), (1)"
ERROR: logging before flag.Parse: E0831 19:27:52.918532 8578 syslogger.go:149] can't connect to syslog
----------------------------------------------------------------------
INSERT INTO sites (site_id) values (1000), (1)
1 myks/10-18: begin
1 myks/10-18: insert into sites(site_id) values (1)
1 myks/18-20: begin
1 myks/18-20: insert into sites(site_id) values (1000)
2 myks/18-20: commit
3 myks/10-18: commit
----------------------------------------------------------------------
$ for site_id in 100 200 300 400; do echo -n "${site_id}:"; vtexplain -shards 32 -vschema-file /tmp/sites.vschema -schema-file /tmp/sites.sql -output-mode json -sql "select * from sites where site_id=${site_id}" 2>/dev/null | jq -r '.[] | .TabletActions | keys[0]' | cut -d/ -f2; done
100:80-88
200:c0-c8
300:88-90
400:58-60
$ cat /tmp/foo
80-88
c0-c8
c0-c8
88-90
58-60
c0-c8
$ sort /tmp/foo | uniq -c
1 58-60
1 80-88
1 88-90
3 c0-c8
Last active
August 31, 2021 20:12
-
-
Save mattlord/22946d6fc7ad697665ee79a1dfd2778b to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment