Repository navigation
fix(reports): rank query fan-out over the whole window, and show per-engine coverage - #764
Merged
Merged
Conversation
…ary 1000 rows getFanoutSnapshot was the fourth section reading its window through an unpaginated select, and the worst of the four: no .range(), no pagination, and no .order() either, so the 1000 rows PostgREST returns were not even a defined slice. On a brand with ~12k answers in the window that is a twelfth of the data, and almost nothing repeats inside it. The section that reported this came out with every one of its ten entries at timesSearched = 2, ordered alphabetically because the counts were all tied. The real top query had been searched 24 times and was not in the list at all. The aggregation moves into SQL alongside the three from 00063, with the same counting rules: a sub-query counts once per answer however often that answer repeats it, and an engine is the item's own source_platform when it has one, otherwise the answer's platform. 220ms for the window above. This does not change which engines appear. Ranking by how many answers ran the identical string favours engines that reuse their phrasing, and that is a separate question from reading the wrong rows.
The table ranks sub-queries by how many answers ran the identical string. That quietly measures how much an engine reuses its phrasing rather than how much it fans out, and the difference is not small: over one week on one brand, ChatGPT issued 3,341 distinct sub-queries to Copilot's 782, and appeared in the top ten exactly never -- its most repeated string ran 9 times against Copilot's 18. Read on its own, the table says ChatGPT does not fan out. It fans out the most. Each engine now carries its distinct sub-query count and the number of answers those came from, above the table. Variety and volume pull in opposite directions here -- Copilot fans out on more answers, ChatGPT with more different queries -- and one number could not have shown that. The ranking itself is unchanged. Whether the top ten should be picked per engine is a larger question about what the section is for, and it is not answered here. The coverage is gathered alongside the ranking, from the same rows and the same window, so the two cannot disagree. Older reports simply have no coverage field and render as before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #762, from a report where Query Fan-out listed only two of the three engines that had actually fanned out. Two separate things were wrong.
The section ranked over an arbitrary 1000 rows
getFanoutSnapshotwas the fourth section reading its window through an unpaginated select, and the worst of the four: no.range(), no pagination, and no.order()either, so the 1000 rows PostgREST returns were not even a defined slice.On a brand with ~12,000 answers in the window that is a twelfth of the data, and almost nothing repeats inside a twelfth. The symptom is visible in the stored payload: all ten entries came out at
timesSearched: 2, listed alphabetically because every count was tied. The real top query had been searched 24 times and was not in the list at all.Now aggregated in SQL alongside the three from #762 (
00064) — 220ms for that window — with the counting rules the fold used: a sub-query counts once per answer however often that answer repeats it, and an engine is the item's ownsource_platformwhen it has one, otherwise the answer's platform.Fixing the rows did not bring the missing engine back
This is the part worth reading. Reading the right 12,000 rows produces the same two engines, because the ranking measures something other than what the section claims to.
Ranking by how many answers ran the identical string rewards an engine for reusing its phrasing. ChatGPT rephrases every time, so it issues more distinct sub-queries than the other two combined and never places in the top ten.
A reader concludes ChatGPT does not fan out. It fans out the most.
So each engine now carries its distinct sub-query count and the answers those came from, above the table (
00065). Two numbers rather than one because they point in opposite directions here — Copilot fans out on more answers, ChatGPT with more different queries — and either alone would mislead in its own way.The ranking itself is untouched. Whether the top ten should be picked per engine is a larger question about what the section is for; this makes the current table honest rather than answering it.
Related issue
None — reported directly from testing, on the report generated after #762.
Type of change
fix— Bug fixMigrations
00064_report_query_fanout_rpc.sqland00065_report_query_fanout_engines.sql. Both already applied to the hosted database. Additive — two new functions nothing referenced yet — so applying before the code that calls them is the safe order.How to test
Needs a brand with several thousand answers in the window.
Verification already done
EXPLAIN ANALYZEon both functions against production data: 220ms and 190ms for a 7-day window on the brand in question.timesSearched: 2, new output 24 / 19 / 18 / 17.yarn typecheck,yarn lint(0 errors),yarn format:check,yarn test(90 passing) andyarn buildpass fromweb/.Not covered by tests — same limitation as #762: nothing in this repo can reach a server action or a Postgres function.
Checklist
feature/,fix/,chore/,docs/)yarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)