Improved performance for filter strings with multiple neq statements (#20198)

ref https://linear.app/tryghost/issue/CFR-27
- updated packages to include performance improvement for NQL filter
strings including multiple neq filters for the same resource
- bumped `bookshelf-plugins`
- bumped NQL versions

We identified a performance fix that allows us to combine not equal
(neq) filters for the same resource in a logically-equivalent way that
also has far more performant resulting SQL.

We're effectively automatically combining strings like
'tag:-tag1+tag:-tag2` into 'tag:-[tag1,tag2]'.
This commit is contained in:
Steve Larson 2024-05-13 10:35:27 -05:00 committed by GitHub
parent e3fa095c80
commit 842290cbef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 118 additions and 78 deletions

View File

@ -41,7 +41,7 @@
"@tryghost/color-utils": "0.2.2",
"@tryghost/kg-unsplash-selector": "^0.1.11",
"@tryghost/limit-service": "^1.2.10",
"@tryghost/nql": "0.12.1",
"@tryghost/nql": "0.12.3",
"@tryghost/timezone-data": "0.4.3",
"react": "18.3.1",
"react-dom": "18.3.1",

View File

@ -49,7 +49,7 @@
"@tryghost/koenig-lexical": "1.1.10",
"@tryghost/limit-service": "1.2.14",
"@tryghost/members-csv": "0.0.0",
"@tryghost/nql": "0.12.1",
"@tryghost/nql": "0.12.3",
"@tryghost/nql-lang": "0.6.1",
"@tryghost/string": "0.2.12",
"@tryghost/timezone-data": "0.4.3",

View File

@ -23,7 +23,7 @@
"c8": "7.14.0",
"mocha": "10.2.0",
"sinon": "15.2.0",
"@tryghost/nql": "0.12.1"
"@tryghost/nql": "0.12.3"
},
"dependencies": {
"@tryghost/mongo-utils": "0.6.1",

View File

@ -30,7 +30,7 @@
"@tryghost/errors": "1.3.2",
"@tryghost/in-memory-repository": "0.0.0",
"@tryghost/logging": "2.4.14",
"@tryghost/nql": "0.12.1",
"@tryghost/nql": "0.12.3",
"@tryghost/nql-filter-expansions": "0.0.0",
"@tryghost/post-events": "0.0.0",
"@tryghost/tpl": "0.1.29",

View File

@ -67,7 +67,7 @@
"@tryghost/api-framework": "0.0.0",
"@tryghost/api-version-compatibility-service": "0.0.0",
"@tryghost/audience-feedback": "0.0.0",
"@tryghost/bookshelf-plugins": "0.6.15",
"@tryghost/bookshelf-plugins": "0.6.17",
"@tryghost/bootstrap-socket": "0.0.0",
"@tryghost/collections": "0.0.0",
"@tryghost/color-utils": "0.2.2",
@ -135,7 +135,7 @@
"@tryghost/mw-version-match": "0.0.0",
"@tryghost/mw-vhost": "0.0.0",
"@tryghost/nodemailer": "0.3.41",
"@tryghost/nql": "0.12.1",
"@tryghost/nql": "0.12.3",
"@tryghost/oembed-service": "0.0.0",
"@tryghost/package-json": "0.0.0",
"@tryghost/post-revisions": "0.0.0",

View File

@ -27,7 +27,7 @@
"dependencies": {
"@tryghost/debug": "0.1.29",
"@tryghost/errors": "1.3.2",
"@tryghost/nql": "0.12.1",
"@tryghost/nql": "0.12.3",
"@tryghost/tpl": "0.1.29",
"lodash": "4.17.21"
}

View File

@ -25,6 +25,6 @@
"sinon": "15.2.0"
},
"dependencies": {
"@tryghost/nql": "0.12.1"
"@tryghost/nql": "0.12.3"
}
}

View File

@ -26,7 +26,7 @@
"dependencies": {
"@tryghost/errors": "1.3.2",
"@tryghost/link-redirects": "0.0.0",
"@tryghost/nql": "0.12.1",
"@tryghost/nql": "0.12.3",
"@tryghost/tpl": "0.1.29",
"bson-objectid": "2.0.4",
"lodash": "4.17.21",

View File

@ -36,7 +36,7 @@
"@tryghost/magic-link": "0.0.0",
"@tryghost/member-events": "0.0.0",
"@tryghost/members-payments": "0.0.0",
"@tryghost/nql": "0.12.1",
"@tryghost/nql": "0.12.3",
"@tryghost/tpl": "0.1.29",
"@tryghost/validator": "0.2.10",
"@types/jsonwebtoken": "9.0.6",

View File

@ -24,7 +24,7 @@
},
"dependencies": {
"@tryghost/errors": "1.3.2",
"@tryghost/nql": "0.12.1",
"@tryghost/nql": "0.12.3",
"@tryghost/post-events": "0.0.0",
"@tryghost/tpl": "0.1.29",
"bson-objectid": "2.0.4"

174
yarn.lock
View File

@ -6719,95 +6719,95 @@
ajv "^6.12.6"
lodash "^4.17.11"
"@tryghost/bookshelf-collision@^0.1.41":
version "0.1.41"
resolved "https://registry.yarnpkg.com/@tryghost/bookshelf-collision/-/bookshelf-collision-0.1.41.tgz#78b11a7089b7f23106688a1d9904a539651b788c"
integrity sha512-v4KaV2Vbh20LIegc3xcxy+loPCFA7Af9wVbt/+VaOlPuwU+5CymMfWADtvaPKD7zB3uCWzOHx5Cz8v++Rk69Ng==
"@tryghost/bookshelf-collision@^0.1.42":
version "0.1.42"
resolved "https://registry.yarnpkg.com/@tryghost/bookshelf-collision/-/bookshelf-collision-0.1.42.tgz#a00db529828b4288381fc882f26ef9e891c178a2"
integrity sha512-WCm7xgHR1HQ9NrJ4AGzOo54dfyztGJBKnKoQK7b3fyRwOXr04e1REGhjCkrDAOnXv0TEKUK4y+loF5d96gKWkg==
dependencies:
"@tryghost/errors" "^1.3.2"
lodash "^4.17.21"
moment-timezone "^0.5.33"
"@tryghost/bookshelf-custom-query@^0.1.24":
version "0.1.24"
resolved "https://registry.yarnpkg.com/@tryghost/bookshelf-custom-query/-/bookshelf-custom-query-0.1.24.tgz#d71fbced623b6fa0008a40f61906097724a4c074"
integrity sha512-ilYR5Fx2Yrz5N0s+NhgxaIeB6mjoUjreAN8gDahJHzHetSMgU/ynuae7ONJhAbh/C5+93j2P3BBylkwuXuPEIw==
"@tryghost/bookshelf-custom-query@^0.1.25":
version "0.1.25"
resolved "https://registry.yarnpkg.com/@tryghost/bookshelf-custom-query/-/bookshelf-custom-query-0.1.25.tgz#b3f7e0e44eb63905631ac0be6de6e500d6fc8087"
integrity sha512-OjKpAL2P9X7BFKOKVD2oAsftUK01AWUBBIuO+FaGosOetIGEeyMZeUV9zI4jB5Us6JNLDiknYzaVZQMd9NsD6w==
"@tryghost/bookshelf-eager-load@^0.1.28":
version "0.1.28"
resolved "https://registry.yarnpkg.com/@tryghost/bookshelf-eager-load/-/bookshelf-eager-load-0.1.28.tgz#ca5127923b0fa7bec725a9a0b1840887db2e34b9"
integrity sha512-EK9ZXUi8HQIT4xMlOnpWfLmor8qizr1PMpMgYO31bzzEKUiq2dqBjJjgrbW2ot7o5HuO9DjoLAfQUbTxxeKzmw==
dependencies:
"@tryghost/debug" "^0.1.29"
lodash "^4.17.21"
"@tryghost/bookshelf-filter@^0.5.12":
version "0.5.12"
resolved "https://registry.yarnpkg.com/@tryghost/bookshelf-filter/-/bookshelf-filter-0.5.12.tgz#fb19f1d435ddaed602ff2ec3a00d82f5f61f6bb6"
integrity sha512-6GlNMAsZX2RzXp6XrgRF5rc1m/nwXYgRWzsEoiFBCsWFW045kuKW6/4UIb/hqltr89S7cIE1ZTRkJCDyjvs9hA==
dependencies:
"@tryghost/debug" "^0.1.29"
"@tryghost/errors" "^1.3.2"
"@tryghost/nql" "^0.12.0"
"@tryghost/tpl" "^0.1.29"
"@tryghost/bookshelf-has-posts@^0.1.29":
"@tryghost/bookshelf-eager-load@^0.1.29":
version "0.1.29"
resolved "https://registry.yarnpkg.com/@tryghost/bookshelf-has-posts/-/bookshelf-has-posts-0.1.29.tgz#f224eccebd950104a971ef81e512aeb6dc9cc615"
integrity sha512-AZ8L7mQdlLnByNQ7C9Eed8d3fltN77kbvunBziEUIZpRPc/AWFfBb6KucMCL/VIo/REQoA+FMEofH41xwTP9lw==
resolved "https://registry.yarnpkg.com/@tryghost/bookshelf-eager-load/-/bookshelf-eager-load-0.1.29.tgz#8d68a709ce3b91055436833f42942de1ced39f09"
integrity sha512-zz1a0D3HER4i2dSRxkA+hTeYZqIdai8Zk+tPYmGTBsm4SrqfQFMR0B9U+FyA8Yn6lCproQx2xFeiCWhThGp9nA==
dependencies:
"@tryghost/debug" "^0.1.29"
"@tryghost/debug" "^0.1.30"
lodash "^4.17.21"
"@tryghost/bookshelf-include-count@^0.3.12":
version "0.3.12"
resolved "https://registry.yarnpkg.com/@tryghost/bookshelf-include-count/-/bookshelf-include-count-0.3.12.tgz#2c28f5076a96e3d1b0f429744a1e1e90ac8dd311"
integrity sha512-MbtyWppy9g9wNyrycbHck+sxvPm62maV8cOL28FBdFB0U8tqP7Z6oU8ov0JABbtWUwZTpbpx6G1d5kYVl2hcxw==
"@tryghost/bookshelf-filter@^0.5.14":
version "0.5.14"
resolved "https://registry.yarnpkg.com/@tryghost/bookshelf-filter/-/bookshelf-filter-0.5.14.tgz#14f5279ccb605a872ae16e5ac49959eb267f4d8d"
integrity sha512-h1dEV9Uq3CvSRCSwTs7Xcx6st2k2aTf0qxqmZppMkiuBKwuijR/e27AFi+n0VfTInYpjkzaiWzAaTs0oijNLJA==
dependencies:
"@tryghost/debug" "^0.1.29"
"@tryghost/debug" "^0.1.30"
"@tryghost/errors" "^1.3.2"
"@tryghost/nql" "^0.12.3"
"@tryghost/tpl" "^0.1.30"
"@tryghost/bookshelf-has-posts@^0.1.30":
version "0.1.30"
resolved "https://registry.yarnpkg.com/@tryghost/bookshelf-has-posts/-/bookshelf-has-posts-0.1.30.tgz#7b842b1defcbd7dce002622ad6be4c4b2a104253"
integrity sha512-KCUSsaVspWhy4TLfruh6Vc4GaecMtBZ2I6zTu1Pei14U/nkhQgiXanpnFGPSzfcswbNyNRxGcOJcqOnr5/BQJg==
dependencies:
"@tryghost/debug" "^0.1.30"
lodash "^4.17.21"
"@tryghost/bookshelf-order@^0.1.24":
version "0.1.24"
resolved "https://registry.yarnpkg.com/@tryghost/bookshelf-order/-/bookshelf-order-0.1.24.tgz#3b20aebf9f90806a1ba2317a97e4b2a027ff3baa"
integrity sha512-iFfvzwOYfpzTWVJ/d8/QyfrZML5zd7xNhvYP1+EuQQLC2TneOFiHssiH1aWIPXa5kPb+UIfvFJMJTlbhqVeqcQ==
"@tryghost/bookshelf-include-count@^0.3.13":
version "0.3.13"
resolved "https://registry.yarnpkg.com/@tryghost/bookshelf-include-count/-/bookshelf-include-count-0.3.13.tgz#0f802d52eda658bd886caebe218f993780ece0fe"
integrity sha512-kz9ziI9yMh4ccyTWkG03WFXhFlVMaA5tJMGVD1AMUQ+0dS/7TnwT1QuUVjspxIYow7LuhuMXDRafgwwOPTuBBA==
dependencies:
"@tryghost/debug" "^0.1.30"
lodash "^4.17.21"
"@tryghost/bookshelf-order@^0.1.25":
version "0.1.25"
resolved "https://registry.yarnpkg.com/@tryghost/bookshelf-order/-/bookshelf-order-0.1.25.tgz#0dbdf6353ad9218e8a2091a14d86fcfb697e4fb6"
integrity sha512-JdHg34oVQ9qUldmp8OgQ352VumbYIV/fQLRLy0lst4AkL6UO9MwV3aCnw74gsLA2Z44KIVhPf9oDfQbuFfmJIw==
dependencies:
lodash "^4.17.21"
"@tryghost/bookshelf-pagination@^0.1.43":
version "0.1.43"
resolved "https://registry.yarnpkg.com/@tryghost/bookshelf-pagination/-/bookshelf-pagination-0.1.43.tgz#a321ea93581133da0e8d7d53d8f6da4ebb6a10c0"
integrity sha512-WJRxd4o91OpqIWHuIdAF7Xc0pP1Nu3P9FZ9qrxKhcz7w2z4MMFog54oPiwHTH5DnOw7V6OfZJ5ECfNcqtntfqg==
"@tryghost/bookshelf-pagination@^0.1.44":
version "0.1.44"
resolved "https://registry.yarnpkg.com/@tryghost/bookshelf-pagination/-/bookshelf-pagination-0.1.44.tgz#597c93c33735f74c22662d4635f9e9c6b26a81cb"
integrity sha512-Le6W5nORcwn3Mnincg7dSwAOc/+nbYwPV5wRaml0+iuh67qJJHkoWt/BZgMrps/c7/zFlAUY05Pts29gCoqXAw==
dependencies:
"@tryghost/errors" "^1.3.2"
"@tryghost/tpl" "^0.1.29"
"@tryghost/tpl" "^0.1.30"
lodash "^4.17.21"
"@tryghost/bookshelf-plugins@0.6.15":
version "0.6.15"
resolved "https://registry.yarnpkg.com/@tryghost/bookshelf-plugins/-/bookshelf-plugins-0.6.15.tgz#4a69e2b1baa39458d0bc92c2753d7f7eb7ba6cb2"
integrity sha512-J62DXdK+dL9f64X1KfioiyE3HEGe4qAJCywq5nbfFPX4/DBoaJq0ZokP8i6/5nJa0UL177mJKf7PTzetUg6MBQ==
"@tryghost/bookshelf-plugins@0.6.17":
version "0.6.17"
resolved "https://registry.yarnpkg.com/@tryghost/bookshelf-plugins/-/bookshelf-plugins-0.6.17.tgz#875b23d5d8abd24c64bba33e0660aadfddad1c7e"
integrity sha512-sstie43C0UhwN/cf55q/C3XxygEgLVCnYXhHkiTSZhL1CBqIFoNxRUgO3piKdMq8smx7C1Q0zROT/T0onNDchg==
dependencies:
"@tryghost/bookshelf-collision" "^0.1.41"
"@tryghost/bookshelf-custom-query" "^0.1.24"
"@tryghost/bookshelf-eager-load" "^0.1.28"
"@tryghost/bookshelf-filter" "^0.5.12"
"@tryghost/bookshelf-has-posts" "^0.1.29"
"@tryghost/bookshelf-include-count" "^0.3.12"
"@tryghost/bookshelf-order" "^0.1.24"
"@tryghost/bookshelf-pagination" "^0.1.43"
"@tryghost/bookshelf-search" "^0.1.24"
"@tryghost/bookshelf-transaction-events" "^0.2.12"
"@tryghost/bookshelf-collision" "^0.1.42"
"@tryghost/bookshelf-custom-query" "^0.1.25"
"@tryghost/bookshelf-eager-load" "^0.1.29"
"@tryghost/bookshelf-filter" "^0.5.14"
"@tryghost/bookshelf-has-posts" "^0.1.30"
"@tryghost/bookshelf-include-count" "^0.3.13"
"@tryghost/bookshelf-order" "^0.1.25"
"@tryghost/bookshelf-pagination" "^0.1.44"
"@tryghost/bookshelf-search" "^0.1.25"
"@tryghost/bookshelf-transaction-events" "^0.2.13"
"@tryghost/bookshelf-search@^0.1.24":
version "0.1.24"
resolved "https://registry.yarnpkg.com/@tryghost/bookshelf-search/-/bookshelf-search-0.1.24.tgz#bf719d0bf76dd3e58a61fb7e7a8d88db7afbd431"
integrity sha512-ddHHGeXgTvh6k7rFG3fSqKtMEb2WWpid/gjBtB7zA1JemB7UrCc9TqvJZrBoAmZJITUYQhNt2N6ZQH6GaT25bg==
"@tryghost/bookshelf-search@^0.1.25":
version "0.1.25"
resolved "https://registry.yarnpkg.com/@tryghost/bookshelf-search/-/bookshelf-search-0.1.25.tgz#9815de91a21d0d3b59b4fbf18e521b1e4b393e0a"
integrity sha512-eU39sSFQ/KCLXrEO2uPXmrNWU31vz7Hq9LdzKe38cyZVHG/ntccMNvvPqPdHbqqkW2E9KoQ67Q61CYGuK446Og==
"@tryghost/bookshelf-transaction-events@^0.2.12":
version "0.2.12"
resolved "https://registry.yarnpkg.com/@tryghost/bookshelf-transaction-events/-/bookshelf-transaction-events-0.2.12.tgz#1a60abe6361352ae9d79ecab775a18586601b7a3"
integrity sha512-9VMac32c60WWzFY7qeZORmxLXYAUnlCtJv2iSWudua0FDMRGSGxvk3s3M7hHI30d74b39Q46WSQ4NdLu5FnH6w==
"@tryghost/bookshelf-transaction-events@^0.2.13":
version "0.2.13"
resolved "https://registry.yarnpkg.com/@tryghost/bookshelf-transaction-events/-/bookshelf-transaction-events-0.2.13.tgz#986a9a8e88bb63963a5bbc850a1be73ede8a2829"
integrity sha512-q0Ww0Bvf1t2wjdJD3J54idN07SF1gQSLPqMRvywEmP1IWbqbXdO4UvAkDQkJuWs8P/AiihXZgO5ykzJFhsq0MQ==
"@tryghost/bunyan-rotating-filestream@^0.0.7":
version "0.0.7"
@ -6862,6 +6862,14 @@
"@tryghost/root-utils" "^0.3.27"
debug "^4.3.1"
"@tryghost/debug@^0.1.30":
version "0.1.30"
resolved "https://registry.yarnpkg.com/@tryghost/debug/-/debug-0.1.30.tgz#1daaac3a6bf63d82f28ba62f515c95dae29b12b4"
integrity sha512-bW/RBkF5QU9iwASVSzdwFM2ba41OWpqe8ffsmblJ+e6z0NPZYuul/n72E/SWyBa8jTVpMLIoxiKG/wO2ajzHWg==
dependencies:
"@tryghost/root-utils" "^0.3.28"
debug "^4.3.1"
"@tryghost/elasticsearch@^3.0.18":
version "3.0.18"
resolved "https://registry.yarnpkg.com/@tryghost/elasticsearch/-/elasticsearch-3.0.18.tgz#27878f43da75f7cc72774ad2a57f5e3be309e978"
@ -7162,6 +7170,13 @@
dependencies:
lodash "^4.17.11"
"@tryghost/mongo-utils@^0.6.2":
version "0.6.2"
resolved "https://registry.yarnpkg.com/@tryghost/mongo-utils/-/mongo-utils-0.6.2.tgz#18af1e057aad6876cb7ff61f817df4e90d8055bf"
integrity sha512-ewXYg2/EOYNc/ko5zwfvxskYfyLOVjMOPGgRLODJf3jLp9iXK9nfLHOrnAO4Jeh9CLzHm84aWUMaRIFH/XQULg==
dependencies:
lodash "^4.17.11"
"@tryghost/nodemailer@0.3.41":
version "0.3.41"
resolved "https://registry.yarnpkg.com/@tryghost/nodemailer/-/nodemailer-0.3.41.tgz#9d9d534fbfa67107b70cdaf20214ce5f8794a291"
@ -7181,7 +7196,17 @@
dependencies:
date-fns "^2.28.0"
"@tryghost/nql@0.12.1", "@tryghost/nql@^0.12.0":
"@tryghost/nql@0.12.3", "@tryghost/nql@^0.12.3":
version "0.12.3"
resolved "https://registry.yarnpkg.com/@tryghost/nql/-/nql-0.12.3.tgz#260f0aed0c3bee85b046fcd8ee24dd567b5ed451"
integrity sha512-bG0U+RMLixLTFkLM4DaL9uDhPCoTlxyMzZOIibZnBHmxi1lMM5cgUEGV38IwD92laIfS2t5BvAONKGhsGoVVVg==
dependencies:
"@tryghost/mongo-knex" "^0.9.0"
"@tryghost/mongo-utils" "^0.6.2"
"@tryghost/nql-lang" "^0.6.1"
mingo "^2.2.2"
"@tryghost/nql@^0.12.0":
version "0.12.1"
resolved "https://registry.yarnpkg.com/@tryghost/nql/-/nql-0.12.1.tgz#da0deb03b9111ac34d70fb07e5db0c4028251ed2"
integrity sha512-UW3+lhyGW3AuGUAsOGsUr0hpkh1KQ2DlcdtZkN0DzU8Bznd7kR0/afOaOqnOdI257pkYmaP7PgGLXcvwTf27+w==
@ -7238,6 +7263,14 @@
caller "^1.0.1"
find-root "^1.1.0"
"@tryghost/root-utils@^0.3.28":
version "0.3.28"
resolved "https://registry.yarnpkg.com/@tryghost/root-utils/-/root-utils-0.3.28.tgz#43ae0047927a7753c9b526ea12ce6e382ec7fb1f"
integrity sha512-/izwMw9tCJIQ3DVHumzEWgKhKAw5FwTgrrYcCNHl89yijJKaVRBOJUhlB/u2ST6UWfhahodjaYauq7ymTItaeg==
dependencies:
caller "^1.0.1"
find-root "^1.1.0"
"@tryghost/server@^0.1.37":
version "0.1.37"
resolved "https://registry.yarnpkg.com/@tryghost/server/-/server-0.1.37.tgz#04ee5671b19a4a5be05e361e293d47eb9c6c2482"
@ -7270,6 +7303,13 @@
dependencies:
lodash.template "^4.5.0"
"@tryghost/tpl@^0.1.30":
version "0.1.30"
resolved "https://registry.yarnpkg.com/@tryghost/tpl/-/tpl-0.1.30.tgz#a012fd800e58d46a7d4146e2bde5f55892d8ae15"
integrity sha512-EhbwSYCTFdK9cXyesCNPFwd3pF6an72vwTeQ9A9IjTVDd4or3wBc6lUwOifxWdYarxhaq2sX67gOn2Js6NbJWg==
dependencies:
lodash.template "^4.5.0"
"@tryghost/url-utils@4.4.8", "@tryghost/url-utils@^4.0.0":
version "4.4.8"
resolved "https://registry.yarnpkg.com/@tryghost/url-utils/-/url-utils-4.4.8.tgz#fb867d8bd59a640dc67ab61c1a3d921bd12a8c2b"