Created
July 21, 2022 14:03
-
-
Save otoolep/2189ef3c6479625f45c03584010084cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create the SQLite file. | |
~ $ sqlite3 test.db | |
SQLite version 3.31.1 2020-01-27 19:55:54 | |
Enter ".help" for usage hints. | |
sqlite> CREATE TABLE test(field1); | |
sqlite> INSERT INTO test | |
...> WITH RECURSIVE | |
...> cte(x) AS ( | |
...> SELECT random() | |
...> UNION ALL | |
...> SELECT random() | |
...> FROM cte | |
...> LIMIT 8000000 | |
...> ) | |
...> SELECT x FROM cte; | |
sqlite> select count(*) from test; | |
8000000 | |
sqlite> | |
~ $ ls -alh test.db | |
-rw-r--r-- 1 philip philip 129M Jul 21 09:59 test.db | |
~ $ file test.db | |
test.db: SQLite 3.x database, last written using SQLite version 3031001 | |
# Start rqlited: | |
./rqlited data | |
# Show that it's empty | |
~ $ curl -G 'localhost:4001/db/query?pretty&timings' --data-urlencode 'q=SELECT count(*) FROM test' | |
{ | |
"results": [ | |
{ | |
"error": "no such table: test" | |
} | |
], | |
"time": 0.000256533 | |
}~ $ | |
# Load the data in 7 seconds: | |
~ $ time curl -v -XPOST localhost:4001/db/load -H "Content-type: application/octet-stream" --data-binary @test.db | |
Note: Unnecessary use of -X or --request, POST is already inferred. | |
* Trying ::1:4001... | |
* TCP_NODELAY set | |
* connect to ::1 port 4001 failed: Connection refused | |
* Trying 127.0.0.1:4001... | |
* TCP_NODELAY set | |
* Connected to localhost (127.0.0.1) port 4001 (#0) | |
> POST /db/load HTTP/1.1 | |
> Host: localhost:4001 | |
> User-Agent: curl/7.68.0 | |
> Accept: */* | |
> Content-type: application/octet-stream | |
> Content-Length: 134787072 | |
> Expect: 100-continue | |
> | |
* Mark bundle as not supporting multiuse | |
< HTTP/1.1 100 Continue | |
* We are completely uploaded and fine | |
* Mark bundle as not supporting multiuse | |
< HTTP/1.1 200 OK | |
< X-Rqlite-Version: 7 | |
< Date: Thu, 21 Jul 2022 14:03:09 GMT | |
< Content-Length: 14 | |
< Content-Type: text/plain; charset=utf-8 | |
< | |
* Connection #0 to host localhost left intact | |
{"results":[]} | |
real 0m7.017s | |
user 0m0.054s | |
sys 0m0.118s | |
# Show that it's there: | |
$ curl -G 'localhost:4001/db/query?pretty&timings' --data-urlencode 'q=SELECT count(*) FROM test' | |
{ | |
"results": [ | |
{ | |
"columns": [ | |
"count(*)" | |
], | |
"types": [ | |
"" | |
], | |
"values": [ | |
[ | |
8000000 | |
] | |
], | |
"time": 0.019724876 | |
} | |
], | |
"time": 0.020131269 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment