{"id":27211154,"url":"https://github.com/lieut-data/test-rpc-database","last_synced_at":"2025-04-10T01:28:35.120Z","repository":{"id":286163901,"uuid":"960576124","full_name":"lieut-data/test-rpc-database","owner":"lieut-data","description":"A benchmark test for connecting to the database with and without RPC.","archived":false,"fork":false,"pushed_at":"2025-04-04T17:15:38.000Z","size":1977,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T18:27:20.345Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lieut-data.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-04-04T17:12:02.000Z","updated_at":"2025-04-04T17:15:42.000Z","dependencies_parsed_at":"2025-04-04T18:38:29.065Z","dependency_job_id":null,"html_url":"https://github.com/lieut-data/test-rpc-database","commit_stats":null,"previous_names":["lieut-data/test-rpc-database"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lieut-data%2Ftest-rpc-database","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lieut-data%2Ftest-rpc-database/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lieut-data%2Ftest-rpc-database/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lieut-data%2Ftest-rpc-database/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lieut-data","download_url":"https://codeload.github.com/lieut-data/test-rpc-database/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248139925,"owners_count":21054200,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-04-10T01:28:34.709Z","updated_at":"2025-04-10T01:28:35.109Z","avatar_url":"https://github.com/lieut-data.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RPC Database Test Plugin\n\nThis plugin is designed to test and compare database performance between RPC-based and direct database access in Mattermost plugins.\n\nIt creates a test table in the Mattermost database, inserts 50,000 records, and measures the time it takes to query this table with configurable batch sizes.\n\n## Features\n\n- Creates a `plugin_test_rpc` table in the Mattermost database\n- Inserts 50,000 test records if they don't exist\n- Provides two API endpoints for performance comparison:\n  - `/api/v1/test`: Uses Mattermost's RPC-based database access via StoreService\n  - `/api/v1/test_raw`: Uses direct SQL connection to the database\n- Supports configurable page sizes via the `page_size` query parameter\n- Returns detailed timing information in JSON format\n\n## Usage\n\nAfter installing the plugin, you can access the database test endpoints at:\n\n```\n# Test using RPC-based database access\n\u003cyour-mattermost-url\u003e/plugins/com.mattermost.test-rpc-database/api/v1/test\n\n# Test using direct database connection\n\u003cyour-mattermost-url\u003e/plugins/com.mattermost.test-rpc-database/api/v1/test_raw\n```\n\n### Query Parameters\n\n- `page_size`: Number of records to fetch in each database query (default: 100)\n  - Example: `/api/v1/test?page_size=10000`\n\n### API Response Example\n\n```json\n{\n  \"insert_time_seconds\": 0,\n  \"total_query_time_seconds\": 0.587083,\n  \"conn_type\": \"rpc\",\n  \"records_queried\": 50000,\n  \"page_size\": 100\n}\n```\n\n## Performance Comparison\n\nThe plugin allows comparing performance between two database access methods:\n\n1. **RPC-based Connection** (via Mattermost's StoreService):  \n   Accesses the database through Mattermost's plugin API abstractions.\n   \n2. **Direct SQL Connection**:  \n   Establishes a direct connection to the database using the database credentials from Mattermost's config.\n\nPerformance varies significantly based on the page size:\n\n| Page Size | RPC-based Time (sec) | Direct SQL Time (sec) | Performance Difference |\n|-----------|----------------------|-----------------------|------------------------|\n| 100       | ~3.26                | ~0.68                 | ~4.8x faster          |\n| 10,000    | ~1.55                | ~0.04                 | ~38x faster           |\n| 50,000    | ~1.51                | ~0.03                 | ~50x faster           |\n\n## Development\n\n### Building the Plugin\n\n```\nmake\n```\n\nThis will produce a single plugin file for upload to your Mattermost server:\n\n```\ndist/com.mattermost.test-rpc-database.tar.gz\n```\n\n### Deploying with Local Mode\n\nIf your Mattermost server is running locally with local mode enabled:\n\n```\nmake deploy\n```\n\n### Using an Experimental Version of Mattermost\n\nTo test with a local/experimental version of Mattermost, edit the `go.mod` file to include this replace directive:\n\n```\nreplace github.com/mattermost/mattermost/server/public =\u003e /path/to/local/mattermost/server/public\n```\n\nThen run `go mod tidy` followed by `make deploy` to build and deploy with the modified dependencies.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flieut-data%2Ftest-rpc-database","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flieut-data%2Ftest-rpc-database","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flieut-data%2Ftest-rpc-database/lists"}