Skip to content

Instantly share code, notes, and snippets.

@Akeboshiwind
Last active May 13, 2024 14:15
Show Gist options
  • Save Akeboshiwind/5c2b4c96240431f29eb97f85d7016adb to your computer and use it in GitHub Desktop.
Save Akeboshiwind/5c2b4c96240431f29eb97f85d7016adb to your computer and use it in GitHub Desktop.
POST large file to xtdb v2
# Run the docker container w/ /tmp/xtdb-data-dir as the data folder
docker run --pull=always -tip 6543:3000 -v /tmp/xtdb-data-dir:/var/lib/xtdb ghcr.io/xtdb/xtdb-standalone-ea
# Verify the initial size:
du -h /tmp/xtdb-data-dir
# (should be 0B)
# Construct a large input file (around 1MB)
echo -n '{"txOps":[{"putDocs":[{"xt/id":1,"doc":"' > /tmp/file
dd if=/dev/urandom bs=786438 count=1 | base64 >> /tmp/file
echo -n '"}],"into":"docs"}]}' >> /tmp/file
# POST the large file 10 times
for run in {1..10}; do curl -X POST -H "Content-Type: application/json" -d @/tmp/file http://localhost:6543/tx; done
# Check again
du -h /tmp/xtdb-data-dir
# (should be around 10MB)
# POST updates to the same doc
for run in {1..10}; do curl -X POST -H "Content-Type: application/json" -d '{"txOps":[{"sql":"UPDATE docs SET price = 340 WHERE docs.xt$id = 1"}]}' http://localhost:6543/tx; done
# Check again
du -h /tmp/xtdb-data-dir
# (should still be around 10MB)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment