{"id":21661099,"url":"https://github.com/soulseekah/metamirror","last_synced_at":"2025-04-11T23:09:01.489Z","repository":{"id":142704812,"uuid":"125393691","full_name":"soulseekah/metamirror","owner":"soulseekah","description":"An experiment in creating mirrored index subsets for the WordPress meta tables","archived":false,"fork":false,"pushed_at":"2018-03-20T18:41:50.000Z","size":50,"stargazers_count":14,"open_issues_count":0,"forks_count":0,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-11T23:08:57.890Z","etag":null,"topics":["database","indexing","mysql","performance","wordpress"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/soulseekah.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2018-03-15T16:11:37.000Z","updated_at":"2022-12-18T18:38:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"27077291-6492-47b8-8452-323fd8b5789e","html_url":"https://github.com/soulseekah/metamirror","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soulseekah%2Fmetamirror","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soulseekah%2Fmetamirror/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soulseekah%2Fmetamirror/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soulseekah%2Fmetamirror/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soulseekah","download_url":"https://codeload.github.com/soulseekah/metamirror/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248492869,"owners_count":21113163,"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":["database","indexing","mysql","performance","wordpress"],"created_at":"2024-11-25T09:43:32.842Z","updated_at":"2025-04-11T23:09:01.484Z","avatar_url":"https://github.com/soulseekah.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# metamirror\n\n[![Build Status](https://travis-ci.org/soulseekah/metamirror.svg?branch=master)](https://travis-ci.org/soulseekah/metamirror)\n\nAn experiment that mirrors subsets of WordPress meta tables for cast-free indexing.\n\n## Background\n\nWordPress stores meta information in key-value structures. Post meta, user meta, term meta, comment meta are all tables with a LONGTEXT `meta_value` that doesn't work well with indexing.\n\nConsider plugins that store numeric values like ratings, pageviews, votecounts. When retrieving objects by these meta values and doing all sorts of math operations on them these values are cast to numeric values (floats or integers). And casting annihilates any indexing there may have been.\n\n## Proposed solution\n\nCreate shadow meta table(s) that house casted values in with an index on them. Add conditional triggers on the core meta tables that insert/delete/update the values into the mirrors with a cast. Add SQL rewriting for SELECT queries detecting meta keys and \"routing\" them to the correct mirror table.\n\n# Installation\n\nDrop in as a plugin.\n\n# Usage\n\n```php\n$mirror = new metamirror\\Mirror( $wpdb-\u003epostmeta, 'INTEGER' );\n$mirror-\u003eadd_meta_key( 'pageviews' );\n$mirror-\u003eadd_meta_key( 'vote%' );\nmetamirror\\Core::add( $mirror );\nmetamirror\\Core::commit();\n```\n\n**Do not call `Core::commit()` every single time!** Just like `flush_rewrite_rules()` it's only meant to be run after adding new mirrors. The mirrors do have to be added either way, but once they're committed, no need to commit again until changes are made. Every commit will **DROP** all the mirror tables and recreate them.\n\n# Warranty\n\nAbsolutely none. **Don't use in production**. Backup before installing or using.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoulseekah%2Fmetamirror","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoulseekah%2Fmetamirror","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoulseekah%2Fmetamirror/lists"}