<div dir="ltr"><div class="gmail_default" style="font-family:tahoma,sans-serif">@John: I don't know of a way, through SQL, to query the cached contains of that special page. Is there a way, or did you mean I should copy data from that special page into a temp table and join from there?<br><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">Also, I am afraid most of the top 500 do have counterparts in FA WP. It is the lower ranks that we are interested in; I guess they fall in top 2000-3000.<br><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">@Jaime: The query which I claimed was slow actually never finished on Quarry; it got killed. The solution you propose (divide and concur) might be my only option on Quarry. But I was hoping that wouldn't be the case.<br><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">I guess I would seize this opportunity to ask two questions:<br><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">1) For people like me who don't have SELECT access to the original tables (what we query is really VIEWs based on the true tables, right?) and therefore cannot see what fields are indexed, is there a place were we can refer to to see the details of indexes available to us for each table?<br><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">2) Even a simple query like below takes forever to run. Assuming that ll_from is indexed (which I think is the case), what makes it so expensive? Shouldn't a simple join on indexed fields + a simple aggregation on an indexed field be relatively cheap?<br><br><span style="font-family:monospace,monospace">page_title, count(cl_to) as CNT from page join categorylinks on page_title = cl_to where page_namespace = 14 group by cl_to;</span><br><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">If anyone reading this has the ability to run EXPLAIN on the above query and share the results, that would be fantastic.<span style="font-family:monospace,monospace"><br></span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 9, 2016 at 3:17 AM, Jaime Crespo <span dir="ltr"><<a href="mailto:jcrespo@wikimedia.org" target="_blank">jcrespo@wikimedia.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I would recommend starting with the appropriate Special page:<br>
[[Special:MostLinkedCategories]]<br>
That generates the 500 categories with most members and is refreshed<br>
every few days.<br>
<br>
If that wasn't enough, I would do:<br>
<br>
 SELECT max(cat_id) FROM category;<br>
<br>
to get the last cat_id, and then, in small, manageable transactions, run:<br>
<br>
 SELECT page_title, cat_pages, cat_subcats, page_id<br>
 FROM category JOIN page ON category.cat_title = page.page_title AND<br>
page.page_namespace = 14<br>
 LEFT JOIN langlinks ON page_id = ll_from and ll_lang = 'fa'<br>
 WHERE cat_id BETWEEN ? and ? and cat_pages > 500 and ll_from is null;<br>
<br>
<br>
where the first 2 "?" are small ranges to cover, in small increments<br>
(e.g. 10000 records each time), between 1 and max(cat_id). Change<br>
"cat_pages > 500" to whatever fits you.<br>
<br>
Double check the where/on s, not 100% sure they are right, but it<br>
should be close to what you want.<br>
<div><div class="h5"><br>
On Wed, Mar 9, 2016 at 4:38 AM, John <<a href="mailto:phoenixoverride@gmail.com">phoenixoverride@gmail.com</a>> wrote:<br>
> I don't have it handy but category membership counts are stored in the db<br>
> use that instead of a count()<br>
><br>
><br>
> On Tuesday, March 8, 2016, Huji Lee <<a href="mailto:huji.huji@gmail.com">huji.huji@gmail.com</a>> wrote:<br>
>><br>
>> I am trying to find a list of those categories on EN WP that are highly<br>
>> used (more than 100 subpages or subcats) but don't have a counterpart in FA<br>
>> WP. The query I used is shown below and also on<br>
>> <a href="https://quarry.wmflabs.org/query/7943" rel="noreferrer" target="_blank">https://quarry.wmflabs.org/query/7943</a> and is extremely slow.<br>
>><br>
>> Any thoughts on how to make it more efficient?<br>
>><br>
>> select page_title, ll_title, count(cl_to) as CNT<br>
>> from page<br>
>> left join langlinks<br>
>> on ll_from = page_id<br>
>> and ll_lang = 'fa'<br>
>> join categorylinks<br>
>> on page_title = cl_to<br>
>> where page_namespace = 14<br>
>> and ll_from is null<br>
>> group by cl_to, ll_title<br>
>> having CNT > 100<br>
>> order by CNT desc;<br>
>><br>
>><br>
><br>
</div></div>> _______________________________________________<br>
> Labs-l mailing list<br>
> <a href="mailto:Labs-l@lists.wikimedia.org">Labs-l@lists.wikimedia.org</a><br>
> <a href="https://lists.wikimedia.org/mailman/listinfo/labs-l" rel="noreferrer" target="_blank">https://lists.wikimedia.org/mailman/listinfo/labs-l</a><br>
><br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
--<br>
Jaime Crespo<br>
<<a href="http://wikimedia.org" rel="noreferrer" target="_blank">http://wikimedia.org</a>><br>
<br>
_______________________________________________<br>
Labs-l mailing list<br>
<a href="mailto:Labs-l@lists.wikimedia.org">Labs-l@lists.wikimedia.org</a><br>
<a href="https://lists.wikimedia.org/mailman/listinfo/labs-l" rel="noreferrer" target="_blank">https://lists.wikimedia.org/mailman/listinfo/labs-l</a><br>
</font></span></blockquote></div><br></div>