### Description:
I am trying to run a query to get the number of pages a certain module is transcluded in from all the wikis from respective databases. The query I am using is this:
```
SELECT page_id, COUNT(tl_from) AS transcluded_in
FROM page
INNER JOIN templatelinks
ON page_title=tl_title
AND page_namespace=828
AND page_content_model='Scribunto'
AND tl_namespace=828
GROUP BY page_id
```
I ran a script in grid from toolforge to do this. This query works fine for all wikis except `enwiki`. I used `LIMIT 500 OFFSET x` to fetch 500 rows at a time due to memory constraints. I got similar MySQL connection errors for another query which got solved by reducing the LIMIT value. But for this particular query in enwiki database, using LIMIT as low as `2` does not seem to work.
To test, I ran the same script in PAWS. Although a little slow, it seems to work just fine and it is executing this query for enwiki with LIMIT 500.
### Steps to Reproduce python script:
# Create a file named `missed_db_info.txt` and write the line `get_templatelinks_info enwiki` in it.
# Clone repo ([[ https://github.com/wikimedia/abstract-wikipedia-data-science/tree/db-info-fetcher | https://github.com/wikimedia/abstract-wikipedia-data-science/tree/db-info-fetcher ]])
# Run the python script ([[ https://github.com/wikimedia/abstract-wikipedia-data-science/blob/db-info-fetcher/fetch_db_info.py | .py file in GitHub ]]) like this `python3 fetch_db_info.py -gm` **in GRID**
# Wait. It takes a few hour to finish (with an error)
### Steps to Reproduce in PAWS:
Run this notebook : [[ https://public.paws.wmcloud.org/User:Aisha_Khatun/enwiki-trasnclusions.ipynb | enwiki-transclusions notebook ]]
### Actual Results:
Getting MySQL connection lost, even after multiple tries.
### Expected Results:
Expected same or better speed from running in grid from toolforge.