Tom,
Thanks for the example. I did the same thing, just not as elegant. When I 
have time, I will try this out.
I also did it for ‘not_null’ since it is called when ‘has_data’ is called. 
For most people, probably not necessary, but I had a sensor offline 
recently, so the default get_aggregate of ‘not_null’ had to iterate until a 
time when the sensor was online. 
Again, thanks!
rich
On Monday 4 March 2024 at 10:41:39 UTC-5 Tom Keffer wrote:

> I've added an optimized version of get_aggregate(). This version 
> recognizes the monotonic relationship between temperature and vapor 
> pressure, so it can use the daily summaries to find the min, max, mintime, 
> and maxtime of vapor pressure. It would not work for the average value.
>
> See 
> https://github.com/weewx/weewx/wiki/XTypes-performance#optimized-version-of-get_aggregate
>
> On Sat, Mar 2, 2024 at 6:52 PM John Kline <[email protected]> wrote:
>
>> It looks like I specialized get_aggregate() for my weewx-purple extension 
>> in July of 2020.  AQI isn’t in the database, but pm2_5 is, which makes 
>> things efficient.
>>
>> I don’t know if get_aggregate was actually called in v4 (since I update 
>> my skin pages on every loop record, the values initially generated in 
>> reports aren’t interesting).
>>
>> I do know that reporting got slower in v5.
>>
>> And this simple change dramatically speeded things up:
>> - weewx.xtypes.xtypes.append(AQI())
>> + weewx.xtypes.xtypes.insert(0, AQI())
>> I’m glad I finally paid attention to this subject.  Thanks, Tom and 
>> others.
>>
>> On Mar 2, 2024, at 5:16 PM, Tom Keffer <[email protected]> wrote:
>>
>> 
>> On Sat, Mar 2, 2024 at 9:38 AM Karen K <[email protected]> wrote:
>>
>>>
>>> First is the ArchiveTable class. It calls the general get_aggregate 
>>> function and thus also your XType. If you want ArchiveTable handle 
>>> get_series aggregations for your XType, you have to insert your XType after 
>>> ArchiveTable. But if you implemented aggregations and do not want 
>>> XTypeTable handle those aggregations, then you need to insert your XTypes 
>>> before XTypeTable. That is, between ArchiveTable and XTypeTable.
>>>
>>
>> I guess I'm not seeing that. If ArchiveTable.get_series() calls 
>> xtypes.get_aggregate(), it will run down the list of xtypes. It won't use 
>> the one in ArchiveTable because it doesn't know about your new type. It 
>> keeps going until it gets to your xtype extension. 
>>  
>>
>>> If your users want to speed up something and include your XTypes into 
>>> the database, they surely want the DailySummaries class handle 
>>> aggregations. But that does not mean that you want XTypeTable handle the 
>>> aggegations of your XType in the other case. You may have provided your own 
>>> implementation of the aggregations. That means you have to insert your 
>>> XType after DailySummaries but before XTypeTable.
>>>
>>
>> If the XType is in the database, it will be handled like any other type. 
>> There is no longer anything special about it. There is no reason for 
>> XTypeTable to come into play. I also don't know why you'd want your own 
>> implementation of get_aggregate() if the type is in the database.
>>
>> So I guess if you want your XType to behave in an intuitive way and you 
>>> have implemented the aggregations, then you will have to insert it after 
>>> ArchiveTable and DailySummaries, but before XTypeTable.
>>>
>>
>> Respectively disagree. New XTypes can be appended or prepended to the 
>> list --- the only time it matters is a straight optimization of 
>> get_aggregate(). Then it must appear at the beginning of the list so it 
>> appears before XTypeTable.get_aggregate().
>>
>> See the new wiki article on xtypes performance 
>> <https://github.com/weewx/weewx/wiki/XTypes-performance>. It explains 
>> some of this.
>>
>> -tk
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "weewx-development" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/weewx-development/CAPq0zEA8h_DYLP6%2BrTB4VeEo46%2B9ySXsfasExohbptVuk8peSw%40mail.gmail.com
>>  
>> <https://groups.google.com/d/msgid/weewx-development/CAPq0zEA8h_DYLP6%2BrTB4VeEo46%2B9ySXsfasExohbptVuk8peSw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-development/c1b54377-63b9-4261-89f6-af80ce29779cn%40googlegroups.com.

Reply via email to