### Install Readyset with Bash Script Source: https://github.com/readysettech/readyset/blob/main/README.md Use this command to quickly install Readyset. Ensure you have curl installed. This is the fastest way to get started. ```bash bash -c "$(curl -sSL https://launch.readyset.io)" ``` -------------------------------- ### Install Readyset Dependencies on Ubuntu Source: https://github.com/readysettech/readyset/blob/main/community-development.md Installs necessary build tools, SSL development libraries, and lz4 development files. ```bash sudo apt update && sudo apt install -y build-essential libssl-dev pkg-config llvm clang libclang-dev liblz4-dev cmake ``` -------------------------------- ### Install Ubuntu Dependencies Source: https://github.com/readysettech/readyset/blob/main/development.md Installs essential development tools and libraries on Ubuntu using apt. ```bash sudo apt update && sudo apt install -y build-essential libssl-dev pkg-config llvm clang liblz4-dev cmake ``` -------------------------------- ### Install Readyset Dependencies on Arch Linux Source: https://github.com/readysettech/readyset/blob/main/community-development.md Installs essential development packages including clang and lz4. ```bash sudo pacman -S base-devel clang lz4 ``` -------------------------------- ### Start Local Development Dependencies Source: https://github.com/readysettech/readyset/blob/main/development.md Sets up and starts local runtime dependencies (Consul, MySQL, Postgres) using Docker Compose. ```bash cp docker-compose.override.yml.example docker-compose.override.yml docker-compose up -d ``` -------------------------------- ### Install Readyset Dependencies with Nix Source: https://github.com/readysettech/readyset/blob/main/community-development.md Enters a Nix shell environment, which should provide the necessary dependencies. ```bash nix-shell ``` -------------------------------- ### Install Readyset Dependencies on CentOS/Amazon Linux Source: https://github.com/readysettech/readyset/blob/main/community-development.md Installs development tools, clang, lz4, and openssl development libraries. ```bash sudo yum -y update sudo yum -y groupinstall "Development Tools" sudo yum -y install clang lz4-devel openssl-devel ``` -------------------------------- ### Install rpm Package Builder Source: https://github.com/readysettech/readyset/blob/main/community-development.md Install the cargo-generate-rpm tool for building rpm packages. Ensure you have Rust and Cargo installed. ```bash cargo install cargo-generate-rpm ``` -------------------------------- ### Install deb Package Builder Source: https://github.com/readysettech/readyset/blob/main/community-development.md Install the cargo-deb tool for building deb packages. Ensure you have Rust and Cargo installed. ```bash cargo install cargo-deb ``` -------------------------------- ### Install Rust via rustup Source: https://github.com/readysettech/readyset/blob/main/development.md Installs Rust using the official rustup script. Ensure the version matches rust-toolchain.toml. ```bash curl https://sh.rustup.rs -sSf | sh ``` -------------------------------- ### Build Readyset from Source Source: https://context7.com/readysettech/readyset/llms.txt Instructions for installing dependencies on Ubuntu, setting up Rust, cloning the Readyset repository, and building the project from source. ```bash # Install dependencies (Ubuntu) sudo apt update && sudo apt install -y \ build-essential libssl-dev pkg-config llvm clang libclang-dev liblz4-dev cmake # Install Rust curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh # Clone and build git clone https://github.com/readysettech/readyset.git cd readyset ``` -------------------------------- ### Install Readyset Dependencies on macOS Source: https://github.com/readysettech/readyset/blob/main/community-development.md Installs lz4 and openssl using homebrew. Configure cargo to find lz4 in the homebrew lib directory. ```bash brew install lz4 openssl ``` ```toml [env] LIBRARY_PATH = "/opt/homebrew/lib" ``` -------------------------------- ### Install Homebrew Dependencies Source: https://github.com/readysettech/readyset/blob/main/development.md Installs lz4 and openssl@1.1 using Homebrew on macOS. ```bash brew install lz4 brew install openssl@1.1 ``` -------------------------------- ### Docker Compose Quickstart (MySQL) Source: https://context7.com/readysettech/readyset/llms.txt Deploy Readyset with MySQL using Docker Compose. Readyset proxies on port 3307. ```yaml # quickstart/compose.mysql.yml (abridged) services: cache: image: docker.io/readysettech/readyset:latest ports: - "3307:3307" - "6034:6034" environment: UPSTREAM_DB_URL: mysql://root:readyset@mysql/testdb LISTEN_ADDRESS: 0.0.0.0:3307 QUERY_CACHING: explicit MYSQL_AUTHENTICATION_METHOD: mysql_native_password mysql: image: mysql:8.0 environment: MYSQL_ROOT_PASSWORD: readyset MYSQL_DATABASE: testdb ``` ```bash docker compose -f quickstart/compose.mysql.yml up -d mysql -h 127.0.0.1 -P 3307 -u root -preadyset testdb ``` -------------------------------- ### Start Backing Databases with Docker Compose Source: https://github.com/readysettech/readyset/blob/main/community-development.md Starts Postgres and MySQL databases in detached mode using Docker Compose. Edit docker-compose.yml to exclude unwanted databases. ```bash docker-compose up -d ``` -------------------------------- ### Get Readyset Version Information Source: https://context7.com/readysettech/readyset/llms.txt Shows the Readyset server version, build profile, and associated build metadata. ```sql SHOW READYSET VERSION; ``` -------------------------------- ### Run Readyset Standalone (MySQL) Source: https://context7.com/readysettech/readyset/llms.txt Start Readyset pointing to an upstream MySQL database. Connect using a standard mysql client. ```bash # Build and run against MySQL cargo run --bin readyset --release -- \ --upstream-db-url=mysql://root:readyset@127.0.0.1:3306/testdb \ --address=0.0.0.0:3307 \ --deployment=myapp \ --prometheus-metrics # Connect via standard mysql client mysql \ --host=127.0.0.1 \ --port=3307 \ --user=root \ --password=readyset \ --database=testdb ``` -------------------------------- ### SELECT Statement Examples Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/hyrise-test-queries.txt Demonstrates basic SELECT statements with different clauses like WHERE, OR, AND, NOT, LIMIT, and UNION. ```sql SELECT * FROM orders; ``` ```sql SELECT a FROM foo WHERE a > 12 OR b > 3 AND NOT c LIMIT 10 ``` ```sql SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY col1; ``` -------------------------------- ### Create Tables for SQL Examples Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/finkelstein82.txt Defines the schema for three tables: people, companies, and schools. These tables are used in subsequent query examples. ```sql CREATE TABLE people (name varchar(100), employer int, age int, experience int, salary int, commission int, education varchar(50)); CREATE TABLE companies (corpname varchar(50), location varchar(2), earnings int, president varchar(100), business varchar(50)); CREATE TABLE schools (schoolname varchar(50), level varchar(50)); ``` -------------------------------- ### INSERT Statement Examples Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/hyrise-test-queries.txt Demonstrates inserting data into a table, both with and without specifying column names. ```sql INSERT INTO test_table VALUES (1, 2, 'test'); ``` ```sql INSERT INTO test_table (id, value, name) VALUES (1, 2, 'test'); ``` -------------------------------- ### Docker Compose Quickstart (PostgreSQL) Source: https://context7.com/readysettech/readyset/llms.txt Deploy Readyset with PostgreSQL, Prometheus, and Grafana using Docker Compose. Connect to Readyset via psql and tear down the stack when finished. ```yaml # quickstart/compose.postgres.yml (abridged) services: cache: image: docker.io/readysettech/readyset:latest ports: - "5433:5433" # SQL proxy port — connect your app here - "6034:6034" # Prometheus metrics environment: UPSTREAM_DB_URL: postgresql://postgres:readyset@postgres/testdb LISTEN_ADDRESS: 0.0.0.0:5433 PROMETHEUS_METRICS: "true" QUERY_CACHING: explicit # Only cache queries you explicitly request QUERY_LOG_MODE: verbose DEPLOYMENT: docker_compose_deployment STORAGE_DIR: /state depends_on: postgres: condition: service_healthy postgres: image: postgres:14 environment: POSTGRES_PASSWORD: readyset POSTGRES_DB: testdb command: ["postgres", "-c", "wal_level=logical"] # Required for replication ``` ```bash # Start the full stack docker compose -f quickstart/compose.postgres.yml up -d # Connect to Readyset via psql psql postgresql://postgres:readyset@127.0.0.1:5433/testdb # Tear down docker compose -f quickstart/compose.postgres.yml down ``` -------------------------------- ### Minimal Failing Input Example Source: https://github.com/readysettech/readyset/blob/main/proptest-stateful/README.md Example of a minimal failing input sequence generated by proptest-stateful after detecting an underflow. ```rust minimal failing input: [ Dec, Dec, Dec, Dec, ] ``` -------------------------------- ### DELETE Statement Examples Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/hyrise-test-queries.txt Shows how to delete rows from a table, with and without a WHERE clause. ```sql DELETE FROM students WHERE grade > 3.0 ``` ```sql DELETE FROM students ``` -------------------------------- ### JOIN Statement Example Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/hyrise-test-queries.txt Illustrates a simple JOIN operation between two tables. ```sql SELECT * FROM t1 JOIN t2 ON c1 = c2; ``` -------------------------------- ### Get Jepsen Test Help Source: https://github.com/readysettech/readyset/blob/main/jepsen/README.md Display command-line help for Jepsen test execution to understand available options. ```shell ❯ lein run test --help ``` -------------------------------- ### GROUP BY and HAVING Clause Example Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/hyrise-test-queries.txt Shows how to group query results and filter them using the HAVING clause. ```sql SELECT a, SUM(b) FROM t2 GROUP BY a HAVING SUM(b) > 100; ``` -------------------------------- ### Pass Parameters to Controller Request Tool Source: https://github.com/readysettech/readyset/blob/main/readyset-tools/README.md Example of how to pass common parameters such as authority, authority-address, and deployment to the controller_request tool. ```bash ./controller_request --authority standalone --authority-address /path --deployment noria --endpoint /healthy_workers ``` -------------------------------- ### UPDATE Statement Examples Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/hyrise-test-queries.txt Illustrates updating rows in a table, with options to update specific columns or all columns. ```sql UPDATE students SET grade = 1.3 WHERE name = 'Max Mustermann'; ``` ```sql UPDATE students SET grade = 1.3, name='Felix Fürstenberg' WHERE name = 'Max Mustermann'; ``` ```sql UPDATE students SET grade = 1.0; ``` -------------------------------- ### Get Customer Discount Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/tpc-w-queries.txt Retrieves the discount percentage for a given customer ID. ```sql SELECT c_discount FROM customer WHERE customer.c_id = ?; ``` -------------------------------- ### Build .deb Package Source: https://context7.com/readysettech/readyset/llms.txt Commands to build a .deb package for Readyset using cargo-deb. Ensure cargo-deb is installed and use the appropriate profiles for building. ```bash cargo install cargo-deb ``` ```bash cargo --locked build --profile=release-dist-quick --bin readyset ``` ```bash cargo deb --no-build --profile=release-dist-quick -p readyset ``` -------------------------------- ### Get New Products by Subject Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/tpc-w-queries.txt Retrieves new products by subject, including author names, ordered by publication date. ```sql SELECT i_id, i_title, a_fname, a_lname FROM item, author WHERE item.i_a_id = author.a_id AND item.i_subject = ? ORDER BY item.i_pub_date DESC,item.i_title limit 50; ``` -------------------------------- ### Get Customer Details by Username Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/tpc-w-queries.txt Retrieves all customer details, including address and country, based on the username. ```sql SELECT * FROM customer, address, country WHERE customer.c_addr_id = address.addr_id AND address.addr_co_id = country.co_id AND customer.c_uname = ?; ``` -------------------------------- ### Enable and Use MCP Server for AI Integration Source: https://context7.com/readysettech/readyset/llms.txt Start Readyset with the Model Context Protocol (MCP) server enabled to allow AI assistants to inspect and manage caches via HTTP. The MCP endpoint is available at the specified address and speaks plain HTTP. ```bash # Start Readyset with MCP enabled readyset \ --upstream-db-url postgresql://postgres:secret@db:5432/myapp \ --address 0.0.0.0:5433 \ --enable-mcp \ --mcp-address 127.0.0.1:6035 # The MCP HTTP endpoint is then available at http://127.0.0.1:6035 # (bind behind a TLS proxy for external access — the endpoint speaks plain HTTP) ``` -------------------------------- ### Serve Jepsen Test Results Source: https://github.com/readysettech/readyset/blob/main/jepsen/README.md Start a local web server to browse Jepsen test results and visualizations. Access the interface via http://localhost:8080. ```shell ❯ lein run serve ``` -------------------------------- ### Implement MysqlShim and Run MysqlIntermediary Source: https://github.com/readysettech/readyset/blob/main/mysql-srv/README.md Implement the `MysqlShim` trait for your backend logic and use `MysqlIntermediary` to run a server that delegates operations. This example shows a shim that always responds with 'no results' and a basic test client. ```rust extern crate mysql; use mysql_srv::*; struct Backend; impl MysqlShim for Backend { fn on_prepare(&mut self, _: &str, info: StatementMetaWriter) -> io::Result<()> { info.reply(42, &[], &[]) } fn on_execute( &mut self, _: u32, _: ParamParser, results: QueryResultWriter, ) -> io::Result<()> { results.completed(0, 0) } fn on_close(&mut self, _: u32) {} fn on_init(&mut self, _: &str, writer: InitWriter) -> io::Result<()> { Ok(()) } fn on_query(&mut self, _: &str, results: QueryResultWriter) -> io::Result<()> { let cols = [ Column { table: "foo".to_string(), column: "a".to_string(), coltype: ColumnType::MYSQL_TYPE_LONGLONG, colflags: ColumnFlags::empty(), }, Column { table: "foo".to_string(), column: "b".to_string(), coltype: ColumnType::MYSQL_TYPE_STRING, colflags: ColumnFlags::empty(), }, ]; let mut rw = results.start(&cols)?; rw.write_col(42)?; rw.write_col("b's value")?; rw.finish() } } fn main() { let listener = net::TcpListener::bind("127.0.0.1:0").unwrap(); let port = listener.local_addr().unwrap().port(); let jh = thread::spawn(move || { if let Ok((s, _)) = listener.accept() { MysqlIntermediary::run_on_tcp(Backend, s, false).unwrap(); } }); let mut db = mysql::Conn::new(&format!("mysql://127.0.0.1:{}", port)).unwrap(); assert_eq!(db.ping(), true); assert_eq!(db.query("SELECT a, b FROM foo").unwrap().count(), 1); drop(db); jh.join().unwrap(); } ``` -------------------------------- ### Configure Readyset with CLI Options and Environment Variables Source: https://context7.com/readysettech/readyset/llms.txt Configure Readyset at startup using command-line flags or their equivalent SCREAMING_SNAKE_CASE environment variables. Options cover database connections, listening addresses, caching modes, metrics, memory limits, and security. ```bash readyset \ --upstream-db-url postgresql://user:pass@host:5432/db \ --address 0.0.0.0:5433 \ --deployment myapp \ --query-caching explicit \ --cache-mode deep \ --prometheus-metrics \ --metrics-address 0.0.0.0:6034 \ --memory-limit 4294967296 \ --default-ttl-ms 10000 \ --allowed-users "app_user:secret,readonly:pass" \ --tls-mode optional \ --readyset-identity-file /path/to/identity.p12 \ --enable-mcp \ --mcp-address 127.0.0.1:6035 \ --deployment-mode standalone ``` -------------------------------- ### TPC-H Query 14: Promotional Revenue Share Source: https://github.com/readysettech/readyset/blob/main/readyset-server/tests/tpc-h-queries.txt Calculates the percentage of revenue generated by promotional parts within a given month. Requires a start date for the month. ```sql CREATE VIEW query_14 AS select 100.00 * sum(case when p_type like 'PROMO%' then l_extendedprice * (1 - l_discount) else 0 end) / sum(l_extendedprice * (1 - l_discount)) as promo_revenue from lineitem, part where l_partkey = p_partkey and l_shipdate >= date ':1' and l_shipdate < date ':1' + interval '1' month; ``` -------------------------------- ### Run ReadySet Server Source: https://github.com/readysettech/readyset/blob/main/development.md Compiles and runs the ReadySet server in release mode. Requires upstream database URL and a deployment name. ```bash cargo run --bin readyset-server --release -- --upstream-db-url --deployment ``` -------------------------------- ### Run Readyset Standalone (PostgreSQL) Source: https://context7.com/readysettech/readyset/llms.txt Build and run Readyset as a single process pointing to an upstream PostgreSQL database. Connect using a standard psql client. ```bash cargo run --bin readyset --release -- \ --upstream-db-url=postgresql://postgres:readyset@127.0.0.1:5432/testdb \ --address=0.0.0.0:5433 \ --deployment=myapp \ --prometheus-metrics # Connect via standard psql client — no application changes needed PGPASSWORD=readyset psql \ --host=127.0.0.1 \ --port=5433 \ --username=postgres \ --dbname=testdb ``` -------------------------------- ### Run Readyset Server Against Postgres Source: https://github.com/readysettech/readyset/blob/main/community-development.md Compiles and runs the Readyset server in release mode, configured to connect to a PostgreSQL upstream database. Includes Prometheus metrics. ```bash cargo run --bin readyset --release -- --database-type=postgresql --upstream-db-url=postgresql://postgres:readyset@127.0.0.1:5432/testdb --address=0.0.0.0:5433 --deployment= --prometheus-metrics ``` -------------------------------- ### Count Started Reviews for a Paper Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/hotcrp-queries.txt Counts the number of reviews that have been started or need submission for a given paper. Useful for tracking review progress. ```sql select count(*) from PaperReview where paperId=? and (reviewSubmitted>0 or reviewNeedsSubmit>0) ``` -------------------------------- ### Create and Push Multi-Arch Manifest Source: https://github.com/readysettech/readyset/blob/main/build/docker/prometheus/README.md Creates a multi-architecture manifest for the readyset-prometheus image, referencing the ARM64 and AMD64 images, and then pushes this manifest to ECR. The --purge flag ensures that any existing manifest with the same tag is removed before pushing the new one. ```bash docker manifest create public.ecr.aws/readyset/readyset-prometheus public.ecr.aws/readyset/readyset-prometheus:latest_linux_arm64 public.ecr.aws/readyset/readyset-prometheus:latest_linux_amd64 docker manifest push --purge public.ecr.aws/readyset/readyset-prometheus ``` -------------------------------- ### Run Readyset Server Against MySQL Source: https://github.com/readysettech/readyset/blob/main/community-development.md Compiles and runs the Readyset server in release mode, configured to connect to a MySQL upstream database. Includes Prometheus metrics. ```bash cargo run --bin readyset --release -- --database-type=mysql --upstream-db-url=mysql://root:readyset@127.0.0.1:3306/testdb --address=0.0.0.0:3307 --deployment= --prometheus-metrics ``` -------------------------------- ### Run ReadySet Adapter for PostgreSQL Source: https://github.com/readysettech/readyset/blob/main/development.md Compiles and runs the ReadySet adapter for PostgreSQL in release mode. Includes options for unauthenticated connections and Prometheus metrics. ```bash cargo run --bin readyset --release -- --database-type postgresql --upstream-db-url postgresql://postgres:readyset@127.1/readyset --allow-unauthenticated-connections --address 0.0.0.0:5433 --deployment --prometheus-metrics ``` -------------------------------- ### Get Item Stock Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/tpc-w-queries.txt Retrieves the current stock quantity for a given item ID. ```sql SELECT i_stock FROM item WHERE i_id = ?; ``` -------------------------------- ### Get Customer Address ID Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/tpc-w-queries.txt Retrieves the address ID associated with a customer ID. ```sql SELECT c_addr_id FROM customer WHERE customer.c_id = ?; ``` -------------------------------- ### Build Release Binary Source: https://context7.com/readysettech/readyset/llms.txt Compile the Readyset project in release mode to generate an optimized binary. ```bash cargo build --release --bin readyset ``` -------------------------------- ### Get Shopping Cart Contents Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/tpc-w-queries.txt Retrieves all items and their details from a specific shopping cart. ```sql SELECT * FROM shopping_cart_line, item WHERE scl_i_id = item.i_id AND scl_sc_id = ?; ``` -------------------------------- ### Run ReadySet Adapter for MySQL Source: https://github.com/readysettech/readyset/blob/main/development.md Compiles and runs the ReadySet adapter for MySQL in release mode. Includes options for unauthenticated connections and Prometheus metrics. ```bash cargo run --bin readyset --release -- --database-type mysql --upstream-db-url mysql://root:readyset@127.1/readyset --allow-unauthenticated-connections --address 0.0.0.0:3307 --deployment --prometheus-metrics ``` -------------------------------- ### Get Customer Password by Username Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/tpc-w-queries.txt Retrieves the password hash for a customer using their username. ```sql SELECT c_passwd FROM customer WHERE c_uname = ?; ``` -------------------------------- ### Get Customer Username by ID Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/tpc-w-queries.txt Retrieves the username of a customer using their customer ID. ```sql SELECT c_uname FROM customer WHERE c_id = ?; ``` -------------------------------- ### Get Related Item 1 Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/tpc-w-queries.txt Retrieves the ID of the first related item for a given item. ```sql SELECT i_related1 FROM item where i_id = ?; ``` -------------------------------- ### Connect to MySQL Shell Source: https://github.com/readysettech/readyset/blob/main/community-development.md Connects to the Readyset-proxied MySQL database using the mysql client. ```bash mysql \ --host=127.0.0.1 \ --port=3307 \ --user=root \ --password=readyset \ --database=testdb ``` -------------------------------- ### Check Query Cacheability with EXPLAIN CREATE CACHE Source: https://context7.com/readysettech/readyset/llms.txt Use EXPLAIN CREATE CACHE FROM to determine if a SQL query is supported by Readyset and the reason for support or lack thereof. This is useful before creating a cache. ```sql -- Check a supported query EXPLAIN CREATE CACHE FROM SELECT id, total FROM orders WHERE customer_id = $1; -- Returns: "yes" — query is cacheable ``` ```sql -- Check an unsupported query EXPLAIN CREATE CACHE FROM SELECT * FROM orders WHERE created_at > now() - interval '1 hour'; -- Returns: "no: queries using non-deterministic functions are not supported" ``` -------------------------------- ### Get Related Items Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/tpc-w-queries.txt Finds related items based on the `i_related` fields in the item table. ```sql SELECT J.i_id,J.i_thumbnail from item I, item J where (I.i_related1 = J.i_id or I.i_related2 = J.i_id or I.i_related3 = J.i_id or I.i_related4 = J.i_id or I.i_related5 = J.i_id) and I.i_id = ?; ``` -------------------------------- ### Connect to Postgres Shell Source: https://github.com/readysettech/readyset/blob/main/community-development.md Connects to the Readyset-proxied Postgres database using the psql client. ```bash PGPASSWORD=readyset psql \ --host=127.0.0.1 \ --port=5433 \ --username=postgres \ --dbname=testdb ``` -------------------------------- ### Get Book Details by ID Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/tpc-w-queries.txt Retrieves all details for a specific book, joining with author information. ```sql SELECT * FROM item,author WHERE item.i_a_id = author.a_id AND i_id = ?; ``` -------------------------------- ### Clone Readyset Repository Source: https://github.com/readysettech/readyset/blob/main/community-development.md Clones the Readyset project from GitHub and navigates into the project directory. ```bash git clone https://github.com/readysettech/readyset.git cd readyset ``` -------------------------------- ### Get Shopping Cart Line Quantity Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/tpc-w-queries.txt Retrieves the quantity of a specific item within a shopping cart. ```sql SELECT scl_qty FROM shopping_cart_line WHERE scl_sc_id = ? AND scl_i_id = ?; ``` -------------------------------- ### Get Customer Name by ID Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/tpc-w-queries.txt Retrieves the first and last name of a customer using their customer ID. ```sql SELECT c_fname,c_lname FROM customer WHERE c_id = ?; ``` -------------------------------- ### Identify Cache Candidates with Readyset Source: https://context7.com/readysettech/readyset/llms.txt Lists queries currently proxied to the upstream database, indicating if they are cacheable and their execution count. Use this to find suitable candidates for `CREATE CACHE`. To see only queries that can be cached, use `SHOW PROXIED SUPPORTED QUERIES`. ```sql SHOW PROXIED QUERIES; ``` ```sql -- Show only queries that CAN be cached (strongest CREATE CACHE candidates) SHOW PROXIED SUPPORTED QUERIES; ``` -------------------------------- ### Invalid ALTER TABLE Statement Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/alter-table.txt This example shows an incomplete ALTER TABLE statement, which would result in an error. ```sql alter table; ``` -------------------------------- ### SELECT with Qualified and Aliased Tables Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/select.txt Shows how to select columns from a specific database and table, and how to use table aliases. ```sql select a from db1.table1; ``` ```sql select table1.a from db1.table1; ``` ```sql select table1.a from db1.table1 as d; ``` -------------------------------- ### Get Country ID by Name Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/tpc-w-queries.txt Retrieves the country ID based on the country name. Used for address validation. ```sql SELECT co_id FROM country WHERE co_name = ?; ``` -------------------------------- ### Get Order Lines by Order ID Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/tpc-w-queries.txt Retrieves all line items for a specific order, joining with item details. ```sql SELECT * FROM order_line, item WHERE ol_o_id = ? AND ol_i_id = i_id; ``` -------------------------------- ### Get Most Recent Order ID by Customer Username Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/tpc-w-queries.txt Retrieves the ID of the most recent order for a customer, identified by their username. ```sql SELECT o_id FROM customer, orders WHERE customer.c_id = orders.o_c_id AND c_uname = ? ORDER BY o_date, orders.o_id DESC limit 1; ``` -------------------------------- ### Show Variables Like Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/hotcrp-queries.txt Retrieves system variables that match a given pattern. ```SQL show variables like ? ``` -------------------------------- ### ModelState Implementation for Counter Source: https://github.com/readysettech/readyset/blob/main/proptest-stateful/README.md Implements the ModelState trait for the Counter example, defining operation generation, execution, and postcondition checks. ```rust #[async_trait(?Send)] impl ModelState for TestState { type Operation = CounterOp; type RunContext = TestContext; type OperationStrategy = BoxedStrategy; fn op_generators(&self) -> Vec { // For each step test, arbitrarily pick Inc or Dec, regardless of the test state: vec![Just(CounterOp::Inc).boxed(), Just(CounterOp::Dec).boxed()] } // No preconditions to worry about or test state to maintain yet fn preconditions_met(&self, _op: &Self::Operation) -> bool { true } fn next_state(&mut self, _op: &Self::Operation) {} async fn init_test_run(&self) -> Self::RunContext { let counter = Counter::new(3); // Start with 3 to make the failing cases more interesting TestContext { counter } } async fn run_op(&self, op: &Self::Operation, ctxt: &mut Self::RunContext) { match op { CounterOp::Inc => ctxt.counter.inc(), CounterOp::Dec => ctxt.counter.dec(), } } async fn check_postconditions(&self, _ctxt: &mut Self::RunContext) {} async fn clean_up_test_run(&self, _ctxt: &mut self::runcontext) {} } ``` -------------------------------- ### Build and Push Docker Images Source: https://github.com/readysettech/readyset/blob/main/build/docker/prometheus/README.md Builds and pushes Docker images for the readyset-prometheus image for both ARM64 and AMD64 architectures. Ensure you are in the directory containing the Dockerfile. ```bash docker build -t public.ecr.aws/readyset/readyset-prometheus:latest_linux_arm64 --platform linux/arm64 . docker build -t public.ecr.aws/readyset/readyset-prometheus:latest_linux_amd64 --platform linux/amd64 . docker push public.ecr.aws/readyset/readyset-prometheus:latest_linux_arm64 docker push public.ecr.aws/readyset/readyset-prometheus:latest_linux_amd64 ``` -------------------------------- ### Create Keystore Cache Source: https://github.com/readysettech/readyset/blob/main/readyset-server/tests/lobsters-schema.txt Creates a cache for keystore entries, allowing retrieval of values based on their keys. Used for system configuration or secrets. ```sql CREATE CACHE q_4 FROM SELECT keystores.`key`, keystores.value FROM keystores WHERE keystores.`key` = ?; ``` -------------------------------- ### Get Order Count Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/tpc-w-queries.txt Retrieves the total count of orders from the orders table. Used to determine the next order ID. ```sql SELECT count(o_id) FROM orders; ``` -------------------------------- ### Create and Push Multi-Arch Manifest Source: https://github.com/readysettech/readyset/blob/main/build/docker/grafana/README.md Creates a Docker manifest for a multi-architecture image and pushes it to the ECR repository. This command aggregates the previously built architecture-specific images under a single tag. ```bash docker manifest create public.ecr.aws/readyset/readyset-grafana:latest public.ecr.aws/readyset/readyset-grafana:latest_linux_arm64 public.ecr.aws/readyset/readyset-grafana:latest_linux_amd64 docker manifest push --purge public.ecr.aws/readyset/readyset-grafana:latest ``` -------------------------------- ### List Snapshotted Tables in Readyset Source: https://context7.com/readysettech/readyset/llms.txt Displays tables that Readyset has snapshotted and is tracking via replication. Caching is only possible for queries over these tables. ```sql SHOW READYSET TABLES; ``` -------------------------------- ### Generate deb Package Source: https://github.com/readysettech/readyset/blob/main/community-development.md Generate a deb package for Readyset after building the binary. Use the --no-build flag if the binary is already built. ```bash cargo deb --no-build --profile=release-dist-quick -p readyset ``` -------------------------------- ### Show Columns Like Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/hotcrp-queries.txt Displays column information for a specified table that matches a given pattern. ```sql show columns from PaperComment like ? ``` -------------------------------- ### Run Noria MySQL Adapter on Default Port Source: https://github.com/readysettech/readyset/blob/main/readyset-mysql/README.md Run the adapter and listen on the default MySQL port (3306). Ensure the DEPLOYMENT environment variable is set. ```console $ cargo run --release -- --deployment $DEPLOYMENT ``` -------------------------------- ### Get Full Order Details Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/tpc-w-queries.txt Retrieves comprehensive details for a specific order, including customer, transaction, shipping, and billing information. ```sql SELECT orders.*, customer.*, cc_xacts.cx_type, ship.addr_street1 AS ship_addr_street1, ship.addr_street2 AS ship_addr_street2, ship.addr_state AS ship_addr_state, ship.addr_zip AS ship_addr_zip, ship_co.co_name AS ship_co_name, bill.addr_street1 AS bill_addr_street1, bill.addr_street2 AS bill_addr_street2, bill.addr_state AS bill_addr_state, bill.addr_zip AS bill_addr_zip, bill_co.co_name AS bill_co_name FROM customer, orders, cc_xacts, address AS ship, country AS ship_co, address AS bill, country AS bill_co WHERE orders.o_id = ? AND cx_o_id = orders.o_id AND customer.c_id = orders.o_c_id AND orders.o_bill_addr_id = bill.addr_id AND bill.addr_co_id = bill_co.co_id AND orders.o_ship_addr_id = ship.addr_id AND ship.addr_co_id = ship_co.co_id AND orders.o_c_id = customer.c_id; ``` -------------------------------- ### Create Cache for Customer Discount Source: https://github.com/readysettech/readyset/blob/main/readyset-server/tests/tpc-w-queries.txt Creates a cache for retrieving a customer's discount. Assumes a 'customer' table with 'c_discount' and 'c_id' columns. ```SQL CREATE CACHE getCDiscount FROM SELECT c_discount FROM customer WHERE customer.c_id = ?; ``` -------------------------------- ### SELECT with Direct Column Comparisons in WHERE Clause Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/select.txt Provides examples of WHERE clauses that directly compare a column to a constant value using various operators. ```sql SELECT n+10 FROM tens WHERE n >= 100; ``` ```sql SELECT n+10 FROM tens WHERE n <100; ``` ```sql SELECT n+10 FROM tens WHERE n >100; ``` ```sql SELECT n+10 FROM tens WHERE n<= 100; ``` ```sql SELECT n+10 FROM tens WHERE n= 100; ``` -------------------------------- ### Get Related Items for Admin Update Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/tpc-w-queries.txt Retrieves item IDs that are frequently ordered with a given item, potentially for updating related items. ```sql SELECT ol_i_id FROM orders, order_line WHERE orders.o_id = order_line.ol_o_id AND NOT (order_line.ol_i_id = ?) AND orders.o_c_id IN (SELECT o_c_id FROM orders, order_line WHERE orders.o_id = order_line.ol_o_id AND orders.o_id > (SELECT MAX(o_id)-10000 FROM orders) AND order_line.ol_i_id = ?) GROUP BY ol_i_id ORDER BY SUM(ol_qty) DESC limit 5; ``` -------------------------------- ### Get Best Sellers by Subject Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/tpc-w-queries.txt Retrieves best-selling items by subject, joining with author and order line information, and grouping by item details. ```sql SELECT i_id, i_title, a_fname, a_lname FROM item, author, order_line WHERE item.i_id = order_line.ol_i_id AND item.i_a_id = author.a_id AND order_line.ol_o_id > (SELECT MAX(o_id)-3333 FROM orders) AND item.i_subject = ? GROUP BY i_id, i_title, a_fname, a_lname ORDER BY SUM(ol_qty) DESC limit 50; ``` -------------------------------- ### CSS for Page Layout Source: https://github.com/readysettech/readyset/blob/main/readyset-server/src/graph.html Basic CSS to ensure the graph takes up the full viewport. No specific setup is required beyond including this in your styles. ```css html, body { margin: 0; padding: 0; height: 100vh; width: 100vw; overflow: hidden; } ``` -------------------------------- ### Create Links Table Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/mediawiki-schema.txt Defines the 'links' table to store internal wiki links. ```sql DROP TABLE IF EXISTS links; CREATE TABLE links ( l_from varchar(255) binary NOT NULL default '', l_to int(8) unsigned NOT NULL default '0' ) TYPE=MyISAM; ``` -------------------------------- ### Plot Benchmark Results Source: https://github.com/readysettech/readyset/blob/main/reader-map/benchmark/README.md Generate plots from the benchmark results log using an R script. Ensure R is installed and plot.r is in the current directory. ```shell R -q --no-readline --no-restore --no-save < plot.r ``` -------------------------------- ### Get Maximum Address ID Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/tpc-w-queries.txt Retrieves the maximum address ID from the address table. Used to determine the next available ID for new addresses. ```sql SELECT max(addr_id) FROM address; ``` -------------------------------- ### CREATE CACHE FROM - Cache a Query Source: https://context7.com/readysettech/readyset/llms.txt Instruct Readyset to create and maintain a materialized view for a SELECT query. Matching queries are served from the cache. Supports explicit naming and parameterized queries. ```sql -- Cache a complex join query CREATE CACHE FROM SELECT count(*) FROM title_ratings JOIN title_basics ON title_ratings.tconst = title_basics.tconst WHERE title_basics.startyear = 2000 AND title_ratings.averagerating > 5; ``` ```sql -- Cache with an explicit name for easy reference CREATE CACHE top_rated_2000 FROM SELECT count(*) FROM title_ratings JOIN title_basics ON title_ratings.tconst = title_basics.tconst WHERE title_basics.startyear = 2000 AND title_ratings.averagerating > 5; ``` ```sql -- Cache a parameterized query (? placeholders work in MySQL, $1 in PostgreSQL) CREATE CACHE FROM SELECT id, name, price FROM products WHERE category = $1 AND price < $2; ``` -------------------------------- ### Get Maximum Customer ID Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/tpc-w-queries.txt Retrieves the maximum customer ID from the customer table. Used to determine the next available ID for new customers. ```sql SELECT max(c_id) FROM customer; ``` -------------------------------- ### Run Noria PostgreSQL Adapter on Custom Port Source: https://github.com/readysettech/readyset/blob/main/readyset-psql/README.md Run the adapter and specify a custom IP address and port for it to listen on. This is useful if another PostgreSQL server is already running on the default port. ```bash $ cargo run --release -- -a : --deployment $DEPLOYMENT_ID ``` -------------------------------- ### Get Paper IDs with Comments by Contact Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/hotcrp-queries.txt Retrieves a list of unique paper IDs for which a given contact has submitted comments. The results are ordered by paper ID. ```SQL select paperId from PaperComment where PaperComment.contactId=? group by paperId order by paperId ``` -------------------------------- ### Create Cache for Keystore Values Source: https://github.com/readysettech/readyset/blob/main/readyset-server/tests/soupy-lobsters-schema.txt Defines a cache for retrieving values from the keystores table based on the key. ```sql CREATE CACHE q_28 FROM SELECT keystores.`key`, keystores.value FROM keystores WHERE keystores.`key` = ?; ``` -------------------------------- ### Get Paper IDs from Reviews by Contact Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/hotcrp-queries.txt Retrieves a list of unique paper IDs for which a given contact has submitted reviews. The results are ordered by paper ID. ```SQL select paperId from PaperReview where PaperReview.contactId=? group by paperId order by paperId ``` -------------------------------- ### Define Test State Structure Source: https://github.com/readysettech/readyset/blob/main/proptest-stateful/README.md Define a struct to hold the model state for your tests. Implement `Default` to set an initial state that matches your test setup. ```rust struct TestState { model_count: usize, } impl Default for TestState { fn default() -> Self { TestState { model_count: 3 } // Set to match initial test value } } ``` -------------------------------- ### Running Stateful Tests with Configuration Source: https://github.com/readysettech/readyset/blob/main/proptest-stateful/README.md Configures and runs stateful tests using proptest-stateful. Adjust min_ops, max_ops, and test_case_timeout as needed. ```rust use proptest::prelude::ProptestConfig; use std::time::Duration; #[test] fn run_cases() { let config = ProptestStatefulConfig { min_ops: 10, max_ops: 20, test_case_timeout: Duration::from_secs(60), proptest_config: ProptestConfig::default(), }; proptest_stateful::test::(config); } ``` -------------------------------- ### TPC-H Query 15: Top Supplier Revenue Source: https://github.com/readysettech/readyset/blob/main/readyset-server/tests/tpc-h-queries.txt Identifies the supplier with the highest total revenue within a specified three-month period. Requires a start date for the period. ```sql CREATE VIEW revenue_s AS select l_suppkey, sum(l_extendedprice * (1 - l_discount)) from lineitem where l_shipdate >= date ':1' and l_shipdate < date ':1' + interval '3' month group by l_suppkey; CREATE VIEW query_15 AS select s_suppkey, s_name, s_address, s_phone, total_revenue from supplier, revenue_s where s_suppkey = supplier_no and total_revenue = ( select max(total_revenue) from revenue_s ) order by s_suppkey; ``` -------------------------------- ### Create User Table Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/mediawiki-schema.txt Defines the 'user' table with user-specific information. Includes unique key on user_id. ```sql DROP TABLE IF EXISTS user; CREATE TABLE user ( user_id int(5) unsigned NOT NULL auto_increment, user_name varchar(255) binary NOT NULL default '', user_rights tinyblob NOT NULL default '', user_password tinyblob NOT NULL default '', user_newpassword tinyblob NOT NULL default '', user_email tinytext NOT NULL default '', user_options blob NOT NULL default '', user_touched char(14) binary NOT NULL default '', UNIQUE KEY user_id (user_id) ) TYPE=MyISAM PACK_KEYS=1; ``` -------------------------------- ### Create VIEW query_06 Source: https://github.com/readysettech/readyset/blob/main/readyset-server/tests/tpc-h-queries.txt Creates a view for query 6, calculating discounted revenue for line items shipped within a specific year and within a discount range. ```sql CREATE VIEW query_06 AS select sum(l_extendedprice * l_discount) as revenue from lineitem where l_shipdate >= date '?' and l_shipdate < date '?' + interval '1' year and l_discount between ? - 0.01 and ? + 0.01 and l_quantity < ?; ``` -------------------------------- ### Get Distinct Paper Tags with Manager/Conflict Filtering Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/hotcrp-queries.txt Retrieves distinct paper tags, filtering papers by submission time and manager contact, including cases where there is no conflict. ```sql select distinct tag from PaperTag t join Paper p on (p.paperId=t.paperId) left join PaperConflict pc on (pc.paperId=t.paperId and pc.contactId=?) where p.timeSubmitted>0 and (p.managerContactId=0 or p.managerContactId=? or pc.conflictType is null) ``` -------------------------------- ### Create Cache for Address Match Source: https://github.com/readysettech/readyset/blob/main/readyset-server/tests/tpc-w-queries.txt Creates a cache to find an existing address based on its components. Assumes an 'address' table. ```SQL CREATE CACHE enterAddressMatch FROM SELECT addr_id FROM address WHERE addr_street1 = ? AND addr_street2 = ? AND addr_city = ? AND addr_addr_state = ? AND addr_zip = ? AND addr_co_id = ?; ``` -------------------------------- ### Build Stripped Readyset Binary Source: https://github.com/readysettech/readyset/blob/main/community-development.md Build a stripped release version of the Readyset binary using Cargo. This command optimizes the binary for distribution. ```bash cargo --locked build --profile=release-dist-quick --bin readyset ``` -------------------------------- ### Get Maximum Review Ordinal for a Paper Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/hotcrp-queries.txt Finds the highest review ordinal number for a given paper. Used to determine the next available ordinal for a new review. ```sql select coalesce(max(reviewOrdinal), 0) from PaperReview where paperId=? group by paperId ``` -------------------------------- ### Select Distinct Paper Tags Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/hotcrp-queries.txt Retrieves a distinct list of tags associated with papers that have been submitted. Use to get a unique set of all tags used for submitted papers. ```sql select distinct tag from PaperTag t join Paper p on (p.paperId=t.paperId) where p.timeSubmitted>0 ``` -------------------------------- ### Select Paper and Review Details with Joins Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/hotcrp-queries.txt Fetches detailed information about papers, their reviews, and associated contact information. This query is used to display comprehensive paper and review data. ```sql select Paper.paperId, reviewId, reviewType, reviewSubmitted, reviewModified, timeApprovalRequested, reviewNeedsSubmit, reviewRound, reviewOrdinal, timeRequested, PaperReview.contactId, lastName, firstName, email from Paper join PaperReview using (paperId) join ContactInfo on (PaperReview.contactId=ContactInfo.contactId) where paperId?a ``` -------------------------------- ### Select Topic Interests Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/hotcrp-queries.txt Retrieves topic interests for a given contact, filtering by non-zero interest values. Used to get a user's specific topic preferences. ```sql select topicId, interest from TopicInterest where contactId=? and interest!=0 ``` -------------------------------- ### Run Concurrent Map Benchmarks Source: https://github.com/readysettech/readyset/blob/main/reader-map/benchmark/README.md Execute the benchmark suite with varying parameters for workers, data distributions, and operations. Results are logged to results.log. ```shell cargo build --release rm results.log for w in 1 2 4; do for d in uniform skewed; do for r in 1 2 4 8 16 32; do target/release/concurrent-map-bench -r $r -w $w -d $d -c | tee -a results.log; done; done; done for e in 2 4 8 16 32 64 128 256 512 1024; do for d in uniform skewed; do target/release/concurrent-map-bench -r 1 -w 1 -d $d -e $e | tee -a results.log; done; done ``` -------------------------------- ### Conditional Operation Generation Source: https://github.com/readysettech/readyset/blob/main/proptest-stateful/README.md Use the current model state to conditionally generate operations. This example only generates the `Dec` operation if the model count is greater than 0, preventing underflow. ```rust fn op_generators(&self) -> Vec { let mut ops = vec![Just(CounterOp::Inc).boxed()]; if self.model_count > 0 { ops.push(Just(CounterOp::Dec).boxed()); } ops } ``` -------------------------------- ### SQL Query with Combined Conditions and NOT EXISTS Source: https://github.com/readysettech/readyset/blob/main/nom-sql/tests/exists-queries.txt This example shows how to combine other filtering conditions (like WHERE x > 3 and y < 3) with a NOT EXISTS clause to create more complex query logic. ```sql SELECT * FROM employees e WHERE x > 3 and not exists (SELECT id FROM eotm_dyn d WHERE d.employeeID = e.id ) and y < 3 ```