News combit Dev Blog

Filtering at Database Level

Posted: Friday, April 11, 2014 | 0 comment(s)
 
Using report parameters has become very popular since we've introduced them in version 19. A typical use case that will become even more seminal with version 20 of our reporting tool is using parameters to filter data (see last feature focus). This is something we've usually put on the "don't" list as databases can filter data much faster than we can. In the past, all records had to be passed to the reporting engine which then decided if a record should be used or not. A vast overhead for a task databases are usually optimized for. In version 20, we'll be introducing a new feature that allows List & Label filter expressions to be translated to native database filters, therefore hugely increasing performance (in principle, depending on the data this is "infinitely" faster).

This feature is supported out of the box by our .NET component. All SQL based DataProviders (SQL Server, Oracle, DB2, PostgreSQL, MySql, SQLite, RSS Bus, Firebird, NuoDB and DbConnectionDataProvider descendants) as well as the AdoDataProvider and XmlDataProvider classes offer thorough support for this feature. We’ll probably be able to add support for the ODataDataProvider as well before the release.
The syntax of a filter expression defined on a table is analyzed and translated to native statements. For SQL, of course, typical traps like SQL injection attack vectors are taken into account. The result of a translated filter is a parametrized SQL WHERE statement. The ADO.NET provider uses RowFilter functions and XML filtering is performed via highly optimized pre-compiled XPath expressions.
 
There are three different modes for a filter:
 
a) Full compatibility to database. Many of the built in functions can be fully translated to native database statements. For the SQL filters, this includes most operators and a huge number of functions (Left$, Right$, Mid$, Round, StartsWith, EndsWith, Contains, Upper$, Lower$, Year, Month, Day, Len, Empty, DateInRange, NumInRange, Artim$, LTrim$, RTrim$). Microsoft's SQL server can support some additional date functions like AddDays, AddWeeks and the like. If a filter uses just these supported functions, it gets automatically translated to a native database query – lightning fast!



b) Partial compatibility to database. This means, a part of an expression can be translated while another part (that is concatenated with "and") can not. In this case, the supported part is performed using native filtering whereas the unsupported part is done by the reporting engine. But it is still quite fast.



c) No compatibility to database. The filtering is performed by the reporting engine. You should try to change the filter condition to a supported syntax or do some pre-filtering beforehand.
 

For custom DataProvider classes, the required interfaces are documented and can be implemented quite easily.
If you're not working with .NET, your language needs to provide support for callbacks and you need to be able to work with VARIANTs. If these features are supported, you can quite easily write your own translation for your custom database system.




Author: Jochen Bartlau
Head of Development List & Label

Jochen Bartlau leads the development at combit as Managing Director. He's a Microsoft .NET enthusiast driving innovation & agile project management. The mobile devices geek who used to be a physicist in his first life loves to spend his spare time with his family.


  

RSS
combit Development BlogRSS
What’s this blog for?
A place to share updates about the ongoing development of our products. General musings on the software industry included.
Archive
January 2021 (1)
December 2020 (2)
November 2020 (1)
October 2020 (2)
September 2020 (1)
August 2020 (2)
July 2020 (1)
June 2020 (1)
May 2020 (2)
April 2020 (2)
March 2020 (2)
February 2020 (1)
January 2020 (1)
December 2019 (1)
November 2019 (2)
October 2019 (2)
September 2019 (2)
August 2019 (2)
July 2019 (2)
June 2019 (2)
May 2019 (1)
April 2019 (0)
April 2019 (1)
March 2019 (1)
February 2019 (1)
January 2019 (1)
December 2018 (1)
November 2018 (2)
October 2018 (4)
September 2018 (4)
August 2018 (2)
July 2018 (2)
June 2018 (2)
May 2018 (1)
April 2018 (1)
March 2018 (1)
February 2018 (2)
January 2018 (1)
December 2017 (1)
November 2017 (2)
October 2017 (3)
September 2017 (3)
August 2017 (2)
July 2017 (2)
June 2017 (1)
May 2017 (2)
April 2017 (1)
March 2017 (1)
February 2017 (1)
January 2017 (2)
December 2016 (1)
November 2016 (1)
October 2016 (4)
September 2016 (5)
August 2016 (2)
July 2016 (2)
June 2016 (3)
May 2016 (2)
April 2016 (3)
March 2016 (3)
February 2016 (1)
January 2016 (2)
December 2015 (2)
November 2015 (1)
October 2015 (4)
September 2015 (5)
August 2015 (2)
July 2015 (2)
June 2015 (2)
May 2015 (1)
April 2015 (2)
March 2015 (1)
February 2015 (1)
January 2015 (1)
December 2014 (2)
November 2014 (1)
October 2014 (1)
September 2014 (2)
August 2014 (1)
July 2014 (2)
June 2014 (1)
May 2014 (2)
April 2014 (1)
March 2014 (2)
+1 800 256 3608 (toll-free North America only)