Wikipedia:Request a query/Archive 7
| This is an archive of past discussions on Wikipedia:Request a query. Do not edit the contents of this page. If you wish to start a new discussion or revive an old one, please do so on the current main page. |
| Archive 1 | ← | Archive 5 | Archive 6 | Archive 7 |
Quarry help
Looking for some Quarry assistance... Trying to write a query that list every Infobox template AND the number of transclusions that each has. Doesn't seem to be working... Any help apprecaited!
SELECT
p.page_title AS template_name,
COUNT(tl.tl_from) AS transclusion_count
FROM page p
LEFT JOIN templatelinks tl
ON p.page_id = tl.tl_target_id
WHERE p.page_namespace = 10
AND p.page_title LIKE 'Infobox%' -- Starts with "Infobox"
AND p.page_title NOT LIKE '%/%' -- Excludes any title containing a slash "/"
AND p.page_is_redirect = 0 -- Exclude redirect templates
GROUP BY p.page_id, p.page_title
ORDER BY transclusion_count DESC;
-- Zackmann (Talk to me/What I been doing) 05:16, 20 June 2026 (UTC)
- mw:Manual:Templatelinks table. tl_target_id is a foreign key into linktarget, not page; this is why it's possible to transclude redlinks. —Cryptic 10:16, 20 June 2026 (UTC)
- @Cryptic: I'll be honest, I don't follow... Can you help me out with what change I can/should make? Zackmann (Talk to me/What I been doing) 21:12, 20 June 2026 (UTC)
- The only thing it makes sense to join templatelinks.tl_target_id to is a lt_id in linktarget. The way you get from there to a row in page is by joining linktarget on namespace and title. The page table only has rows for pages that actually exist, so templatelinks can't logically point at a page_id for its target, or you wouldn't be able to see entries in Special:Whatlinkshere for redlinked templates. Before the linktarget table was created a couple years ago, templatelinks had columns for the transcluded template's namespace and title instead of the current tl_target_id.Whether the current iteration of your query at quarry:query/106488 is correct depends on what precisely you're looking for. There's two things you can do that make sense here: look at all transclusions of templates named 'Infobox%', whether the template being transcluded actually exists or not; or look at all templates named 'Infobox%', whether they're ever transcluded or not. In the first case, you won't be able to see existing templates that aren't transcluded anywhere; in the second, you won't be able to see failed attempts to transclude appropriately-named templates that are redlinks. The current version on Quarry does the first; your query above looks like an attempt to do the second. To make it actually do it correctly, add a
LEFT JOIN linktarget ON lt_namespace = page_namespace AND lt_title = page_titleand change the join condition for templatelinks to beON tl_target_id = lt_id.Though, to be honest, it probably doesn't make a lot of difference either way, what with the LIMIT 1000 - if there's ever any redlinked infobox templates being transcluded that many times, it's almost certainly because they were just deleted and they're waiting to be depopulated (for the first query), and there's well over a thousand existing template pages that are transcluded (for the second). The second query does make it a little more straightforward to exclude redirects, at least; in the first, those will be counted both the titles for the template redirect and the template it's pointing to. There's about 270 such redirects in your results. The highest among those is Template:Infobox NFL biography→Template:Infobox gridiron football biography with 27321 transclusions through the redirect out of 39664 total to the target template. —Cryptic 02:54, 21 June 2026 (UTC)
- The only thing it makes sense to join templatelinks.tl_target_id to is a lt_id in linktarget. The way you get from there to a row in page is by joining linktarget on namespace and title. The page table only has rows for pages that actually exist, so templatelinks can't logically point at a page_id for its target, or you wouldn't be able to see entries in Special:Whatlinkshere for redlinked templates. Before the linktarget table was created a couple years ago, templatelinks had columns for the transcluded template's namespace and title instead of the current tl_target_id.Whether the current iteration of your query at quarry:query/106488 is correct depends on what precisely you're looking for. There's two things you can do that make sense here: look at all transclusions of templates named 'Infobox%', whether the template being transcluded actually exists or not; or look at all templates named 'Infobox%', whether they're ever transcluded or not. In the first case, you won't be able to see existing templates that aren't transcluded anywhere; in the second, you won't be able to see failed attempts to transclude appropriately-named templates that are redlinks. The current version on Quarry does the first; your query above looks like an attempt to do the second. To make it actually do it correctly, add a
- @Cryptic: I'll be honest, I don't follow... Can you help me out with what change I can/should make? Zackmann (Talk to me/What I been doing) 21:12, 20 June 2026 (UTC)
- Are you working on a way to automate the counts in Wikipedia:List of infoboxes? If so, I will remove it from my TODO list...
— GhostInTheMachine talk to me 10:22, 21 June 2026 (UTC)
Top-level user pages that are categorized into categories which have Template:Template category
I cobbled together a query – quarry:query/106853 – that uses the name of the category, but this is a bad idea, because of false positives (e.g. Category:Wikipedians who program conditional templates and Category:Pages using New York City Subway service templates – categories only related to templates, but aren't template categories) and false negatives (e.g. Category:Navigational boxes, name of which doesn't end in the word "templates").
Could someone please help rewrite the part for checking if a category is a template category from checking its name to checking the presence of Template:Template category? This is needed to remove incorrect categorizations such as Special:Diff/1361893658. —andrybak (talk) 18:52, 30 June 2026 (UTC)
- An alternative to checking Template:Template category is to check whether the candidate for template category is in Category:Wikipedia template categories. —andrybak (talk) 19:20, 30 June 2026 (UTC)
- quarry:query/106856 (sans alternative]). —Cryptic 19:32, 30 June 2026 (UTC)
database query: Unusualy short IPv6 range blocks
I want it because they are very uncommon and definiton is: range blocks with subnet smaller than /64 ~2026-31625-14 (talk) 04:06, 29 June 2026 (UTC)
- quarry:query/106854. Far more uncommon than I would've guessed.This is only currently-blocked addresses (and excludes autoblocks). It's not feasible to find expired or removed blocks; there's far too many to look through and no useful indices. —Cryptic 19:17, 30 June 2026 (UTC)
- @Cryptic also make a query where IPv6 blocks address did not start with 2 ~2026-33676-45 (talk) 02:55, 1 July 2026 (UTC)
- No current blocks, and only one historic one. It was a typo. —Cryptic 05:08, 1 July 2026 (UTC)
- @Cryptic please also query legacy ip countribution for any IPv6 adress not starting with 2 ~2026-31625-14 (talk) 06:21, 1 July 2026 (UTC)
- quarry:query/106964. Six edits among three ips, all still live. —Cryptic 20:27, 3 July 2026 (UTC)
- @Cryptic please also query legacy ip countribution for any IPv6 adress not starting with 2 ~2026-31625-14 (talk) 06:21, 1 July 2026 (UTC)
- No current blocks, and only one historic one. It was a typo. —Cryptic 05:08, 1 July 2026 (UTC)
- @Cryptic also make a query where IPv6 blocks address did not start with 2 ~2026-33676-45 (talk) 02:55, 1 July 2026 (UTC)
Fetching page title in regex
I'm interested in using AWB to help make redundant section names more concise, e.g. changing "Perceptions of red tape" to just "Perceptions" at Red tape. However, to make a regex query for this, I'd need to fetch the article title to compare it to the section title. Is this possible? And how would I make a list of articles where this change could be considered? Sdkb talk 05:00, 2 July 2026 (UTC)
- Might be better to request a query, as I'm not sure a blanket search would be able to find something like that. Primefac (talk) 06:18, 2 July 2026 (UTC)
- Within JWB (and, I assume, AWB), $x refers to the page title. However, finding which pages to edit is hard.
- I don't think Wikipedia's search (Cirrus) can do this, as it has no syntax to access the page title. We can't even cunningly search for text like
'''Red tape''' is .* Red tape==because its regex implementation lacks backreferences. The main resource used at "Request a query" is Quarry, which runs on a database which does not contain the page text, or even section headings. I don't think that works here, but someone who monitors that page might have a bright idea. I doubt that PetScan could do the job either. It would probably need simple custom software run on the large database dump. Certes (talk) 18:29, 2 July 2026 (UTC)- Gah, I thought Quarry had in-text (I feel like I've seen it). Petscan has an insource search but last I looked it was only in-text and couldn't necessarily be used to bodge this. Primefac (talk) 06:24, 3 July 2026 (UTC)
- Only indirectly, through the same sorts of things you can see in Special:Whatlinkshere and Special:Linksearch (that is, redirects, transclusions, links, and external links). If there's a redirect to an article's section, the section name can be found, but the overwhelming majority of sections don't have such redirects. So yeah, I agree with Certes: the most practical way forward is working with a full text dump. —Cryptic 20:11, 3 July 2026 (UTC)
- PetScan allows an insource search, which it can combine with other searches in useful ways (e.g. pages containing insource:/xyx/ which are in Category:Whatever but not linked from article Foo.) However, although it can be post-processed cleverly, it's just the standard Cirrus search. Certes (talk) 22:09, 3 July 2026 (UTC)
- Gah, I thought Quarry had in-text (I feel like I've seen it). Petscan has an insource search but last I looked it was only in-text and couldn't necessarily be used to bodge this. Primefac (talk) 06:24, 3 July 2026 (UTC)
Query for pages with 1,250 or more images
Parsoid has a limit of 1,250 images per page, but there is no tracking category yet. See T430854 for details.
https://quarry.wmcloud.org/query/107136 purports to list pages with more than 1,250 images, but I think it is showing page IDs instead of page titles. I suppose I could ask ChatGPT for SQL, but I'd rather ask a human. Can someone please modify this query to output page titles including namespace names (e.g. "List of flags" or "Wikipedia:WikiProject flags/list of flags"), along with the number of images on each page? – Jonesey95 (talk) 19:57, 9 July 2026 (UTC)
- quarry:query/107149, but I don't think it or the original query do what they need to - they show pages with at least 1250 different images, and (without having actually looked at the source to confirm) I suspect the actual limit is for total images. —Cryptic 20:34, 9 July 2026 (UTC)
- (You could've gotten to the pages without this, btw, with e.g. Special:Redirect/page/17179817. —Cryptic 20:35, 9 July 2026 (UTC))
Student edits per year
- How many edits to the mainspace (only) do Wiki Edu students make in a year? If it's convenient, then there's a complete list of all Wiki Edu students from 2023 in User:WhatamIdoing/Student accounts in 2023.
- How many edits to the mainspace (only) do non-students make in a year?
If it's in the mainspace now, that's fine. I'm mainly trying to exclude talk-page comments, The Wikipedia Adventure, bots, and other non-article edits.
My goal is to write a sentence such as "Wiki Edu students contribute n% of all edits to articles each year." @Tryptofish may be interested in the answer as well. WhatamIdoing (talk) 00:44, 18 July 2026 (UTC)
- I don't think this is good data.
- 23 of the users there don't exist: User:4caddit, User:Atrowbridge1, User:Chanel.Young001, User:Cozycardigan, User:Ellieghayward, User:Enginhori, User:Erfowler1, User:Grape Jelly Toast, User:Hannahcheney, User:Isab.6703, User:Isabellalopexx, User:Karlaneaudet, User:Kelsh9610, User:KoreanChristianAmerican, User:KylieRumsey23, User:Ladyoflorien75, User:LunaSHSU, User:Nadpnw, User:Nataliehermosill0, User:Ninambeans, User:PunxsutawneyPhilPennsylvania, User:Ssharmin825, User:Zestychickensalad. Following redirects isn't practical on this scale, even for the users who hadn't deleted their userpage either before or after renaming, and even with the reasonable assumption that the redirect targets are always accurate. Following the page move or rename logs is much less so. I guess if I was thinking I'd have just updated your subpage to fix these.
- Near as I can tell, this only has the student users active in the program in 2023. There are 12294 registered in 2023, 172 in 2022, 59 in 2021, 33 in 2020, and 52 total in 2005-2019. Ideally this query should use a list of all students ever, but even assuming that almost all of them stop editing when their course is over, I'd be more confident of the results if I had at least a list of students enrolled in the current and previous years for the year I'm querying.
- That said, quarry:query/107417. 0.18% in 2023. —Cryptic 19:00, 18 July 2026 (UTC)
- In round numbers, we're looking at (for 2023):
- Students made about 75,000 edits to articles
- IPs made about 7,000,000 edits to articles
- Non-student registered editors made about 30,000,000 edits to articles
- This works out to 0.18% of mainspace edits, or a little less than 1 in 500 mainspace edits. Thanks. WhatamIdoing (talk) 19:57, 18 July 2026 (UTC)
- Responding to the ping, I can think of two, opposite, ways of looking at this data. One is that student edits make only an insignificant contribution to Wikipedia content, and probably never will. The other is that student edits are unlikely to be a major contributor to problem edits, because they are such a small percentage. I'm inclined to think that both of these interpretations are at least partially wrong, because the analysis does not distinguish between different edits in terms of the quality of the contribution. (On the other hand, there is something unrelated to student editing, that looks statistically significant here: registered editors make a lot more content edits than IP/temp accounts do. I hadn't expected that.) --Tryptofish (talk) 20:46, 18 July 2026 (UTC)
- Registered editors have Wikipedia:AutoWikiBrowser and other tools that make high-volume editing possible, and we can edit semi-protected pages (which tend to get more edits), so it's not surprising if we make most of the edits.
- I think you are correct about both interpretations having a problem with Wikipedia:Editcountitis. We could re-run the numbers for just unreverted edits, and we might be able to do something about edit size. Adding two paragraphs and two sources is more significant than fixing a typo (and I say that even though my own first edit was almost certainly fixing a punctuation error). I should go clean up the list of editors who changed their usernames (or maybe get a 2025 list instead) before we try anything else. WhatamIdoing (talk) 20:54, 18 July 2026 (UTC)
- Responding to the ping, I can think of two, opposite, ways of looking at this data. One is that student edits make only an insignificant contribution to Wikipedia content, and probably never will. The other is that student edits are unlikely to be a major contributor to problem edits, because they are such a small percentage. I'm inclined to think that both of these interpretations are at least partially wrong, because the analysis does not distinguish between different edits in terms of the quality of the contribution. (On the other hand, there is something unrelated to student editing, that looks statistically significant here: registered editors make a lot more content edits than IP/temp accounts do. I hadn't expected that.) --Tryptofish (talk) 20:46, 18 July 2026 (UTC)
- In round numbers, we're looking at (for 2023):
- Subscribed. Mathglot (talk) 21:15, 18 July 2026 (UTC)