DB-murdering API query (index suggestions needed)

Stewart Smith stewart at flamingspork.com
Sat Nov 16 04:04:49 AEDT 2019


> On 15 Nov 2019, at 05:48, Daniel Axtens <dja at axtens.net> wrote:
> 
> 
>> 
>> Today, the DB behind patchwork.kernel.org was in a semi-permanent state 
>> of suffering due to someone trying to suck down all patches in the 
>> linux-arm-kernel project. This is what the API request looked like:
>> 
>> GET /api/1.1/patches/?project=62&before=2019-11-01T00:00:00&per_page=100&page=6150 
>> 
>> The query behind this takes about 1 minute to run on a 20-core HT Xeon 
>> system and requires creating a huge temporary file (there are 18375 
>> patches in that project).
> 
> Ouch, I'm sorry to hear that.
> 
>> 
>> So, two questions, really:
>> 
>> 1. Any indexes we can put in place to make this query perform better?
> 
> We have a bunch of db magic contributed by Stewart that will hit 2.2.
> 
> Stewart, do you happen to know if any of your magic will affect API
> queries? They're advertised as affecting the general listing of patches
> in the UI, I'm not sure if they also affect this.
> 
> If not, we can definitely have a look at getting an index or rate
> limiting/authentication thingy in for 2.2.

I am pretty sure that my improvements would help in that specific query, probably not enough to be ideal though. I know they improve the web site equivalent operation, but don’t remember how much (if any) I poked at the API there.

I could take a look, I’d just need to set up a dev environment and grab a good set of data again.


More information about the Patchwork mailing list