# Max\_statement\_time exceeded in Lasair filter

**URL:** <https://www.rubin.community/t/max-statement-time-exceeded-in-lasair-filter/7780>\
**Category:** Lasair\
**Created:** [July 24, 2023, 1:09pm UTC](https://www.rubin.community/t/max-statement-time-exceeded-in-lasair-filter/7780 "2023-07-24T13:09:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChrisFro](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/chrisfro/32/4082_2.png) [@ChrisFro](https://www.rubin.community/u/ChrisFro)\
**Post date:** [July 24, 2023, 1:09pm UTC](https://www.rubin.community/t/max-statement-time-exceeded-in-lasair-filter/7780/1 "2023-07-24T13:09:03Z")

</div>

Hi,  
I have a filter that’s been running for a couple of years without problems, however, in the past few days I get this error message:

```auto
1969 (70100): Query execution was interrupted (max_statement_time exceeded)

```

Has the execution time changed recently? I see the query is performed as

```auto
SET STATEMENT max_statement_time=10 FOR SELECT blah blah

```

Is there any way to increase this?

Cheers,  
Chris

---

<div class="post-metadata">

**Author:** ![roy](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/roy/32/1254_2.png) [@roy](https://www.rubin.community/u/roy)\
**Post date:** [July 24, 2023, 3:02pm UTC](https://www.rubin.community/t/max-statement-time-exceeded-in-lasair-filter/7780/2 "2023-07-24T15:02:56Z")

</div>

Can you give me the filter ID? The number in the URL after /filters/

---

<div class="post-metadata">

**Author:** ![ChrisFro](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/chrisfro/32/4082_2.png) [@ChrisFro](https://www.rubin.community/u/ChrisFro)\
**Post date:** [July 24, 2023, 3:11pm UTC](https://www.rubin.community/t/max-statement-time-exceeded-in-lasair-filter/7780/3 "2023-07-24T15:11:13Z")

</div>

Sure: 777

---

<div class="post-metadata">

**Author:** ![roy](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/roy/32/1254_2.png) [@roy](https://www.rubin.community/u/roy)\
**Post date:** [July 25, 2023, 7:50am UTC](https://www.rubin.community/t/max-statement-time-exceeded-in-lasair-filter/7780/4 "2023-07-25T07:50:53Z")

</div>

OK I changed it to 60 second timeout. Can you try again?

When you run the query by clicking the web page, it is against the many millions in the archive.

When the query runs during alert ingestion, it is against a few thousands in the latest batch. That needs to execute in 10 seconds or less or else hold up the pipeline.

---

<div class="post-metadata">

**Author:** ![ChrisFro](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/chrisfro/32/4082_2.png) [@ChrisFro](https://www.rubin.community/u/ChrisFro)\
**Post date:** [July 31, 2023, 10:22am UTC](https://www.rubin.community/t/max-statement-time-exceeded-in-lasair-filter/7780/5 "2023-07-31T10:22:18Z")

</div>

It works now, thanks.

I’ve set up these filters as streams now as well. Would you recommend using “History” rather than “Run Filter” as my routine to visually inspect recent transients?

---

<div class="post-metadata">

**Author:** ![roy](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/roy/32/1254_2.png) [@roy](https://www.rubin.community/u/roy)\
**Post date:** [August 15, 2023, 6:58am UTC](https://www.rubin.community/t/max-statement-time-exceeded-in-lasair-filter/7780/6 "2023-08-15T06:58:39Z")

</div>

Chris – Finally I am ready to answer your question about History versus RunFilter. There were some bugs and some issues and some fixes and pushes, but now we are OK. Lasair relies on the idea that running a SELECT filter on the website or API delivers the same results as when that filter is made active with Kafka/Email. You basically get the same results.

BUT this is not true if your filter includes sorting with ORDER BY. See for example [order\_of\_brightness](https://lasair-ztf.lsst.ac.uk/filters/log/lasair_855order_of_brightness/) filter, which includes the clause `ORDER BY objects.gmag`. If you click “Run Filter”, you get the brightest first, obviously. But the History reflects what went out from the streaming filter, which is **always** in time order, no matter what you said in the ORDER BY. The streaming is done on batches of 40,000 alerts, one every few minutes, so it orders within the batch only, not on the entire result. – Roy

---

<div class="post-metadata">

**Author:** ![roy](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/roy/32/1254_2.png) [@roy](https://www.rubin.community/u/roy)\
**Post date:** [August 15, 2023, 7:00am UTC](https://www.rubin.community/t/max-statement-time-exceeded-in-lasair-filter/7780/7 "2023-08-15T07:00:14Z")

</div>

For your visual inspection, probably the best thing would be to get email output. This is restricted to one message per 24 hours, as a digest. We have had a bit of trouble with emails not getting through, would be great if you could try this setting and tell me if it works.
