If you have been a CRM developer for a length of time then you will certainly come across filtered views and they are useful and definitely something you should learn more about, particularly if you are going to be writing reports or accessing the CRM database directly.
The CRM database can be viewed and the data used but never changed directly – Hosk
- Direct changes to the SQL table are unsupported, this will result in Microsoft offering no or limited support if your CRM installation goes wrong. You can read more about why you should not create unsupported changes here
- When you use the CRM SDK to change a value it could update other fields and values, direct changes to the SQL will not
- There is no validation on the SQL tables, you could easily put in an incorrect value
- If you write SQL stored procedure directly against the CRM database tables this could stop working when a rollup or service patch is applied to your CRM organisation
You should be of the opinion directly changing values on the Microsoft CRM database is a big no no
Best practice is to avoid accessing fields directly from CRM tables, the database structure, tables and fields could all change in future releases, rollups and service packs.
So what is the alternative to accessing CRM data using SQL if you shouldn’t access the data directly?
Microsoft have created a filtered view for each database table and Microsoft will make sure these work even after future releases, rollups and services packs.
Start with the CRM database

- Data Access Platform
- Filtered SQL Views
What are filtered views?
Entity schema name | Entity type code | Report view name | Description |
---|---|---|---|
Account | 1 | FilteredAccount | Business that represents a customer or potential customer. The company that is billed in business transactions. |
AccountLeads | 16 | FilteredAccountLeads | Represents the intersect table for the accountleads_associationrelationship. |
- Filtered views have the same name as the CRM table but with the word Filtered prefixing it. Not all Entities have filtered views because some entities are system entities
- Filtered views will be automatically created for any custom entities you create.
- In CRM 2011 the filtered view contained all the fields in the base and the extended table.
- CRM filtered views exist for individual activity types e.g. (email, task, letter, etc)
Why are Filtered views cool
The benefits of Filtered views are
- Filtered views won’t break after patches, services releases and maybe upgrades
- Security is embedded in the view
- All the column names are in lower case
- Filtered views are automatically created and updated for custom entities
- Datetime fields are held in datetime and UTC
- Drop down values are held in filtered views
Filtered views won’t break after patches, services releases and maybe upgrades
Security is embedded in the view
Filtered views are created for CRM developers to use in reports. Filtered views use the Microsoft Dynamics CRM security model, so data shown in a report using a filtered view would only contain the data the users can view in CRM.
Filtered views take uses security levels e.g. organisation, business unit, owner and field level and these only show the levels each individual user can see.
If you created a view created directly on the Microsoft Dynamics CRM tables then it would show all the data to all users.
Adam summarises this excellently in his comment
Filtered views enforce security
All the column names are in lower case
All the column names in a filtered view are in lower case, so you do not have any problems with case sensitivity
Filtered views are automatically created and updated for custom entities
Microsoft is busy in the background and when you create a new entity or add fields to a custom entity or System entity, Microsoft automatically creates a new filtered view for custom entities and adds the new fields to existing filtered views.
Datetime fields are held in datetime and UTC
Filtered views have two datetime fields for every date time field you add. One DateTime field and one UTC DateTime field.
The DateTime field holds the date time for the users time zone
DateTime UTC holds the time in UTC
Drop down values are held in filtered views
Option sets have two fields in a filtered view, one holds the value the other holds the string representation
One field holds the string value of the option set
Another value holds the number
If you had an option set field accountrating with an option set value set of Gold – 1.
accountrating = 1
accountratingname = “Gold”
Primary Key Field
Denormalisation
In computing, denormalization is the process of attempting to optimize the read performance of a database by adding redundant data or by grouping data.[1][2] In some cases, denormalization is a means of addressing performance or scalability in relational database software.
- Guid
- Name
Problems with Filtered Views
- Lots of Teams in different BU’s
- Lots of sharing
Great post. A thank you from Brazil.
LikeLike
Great article. Every crm developer should read. Thanks.
LikeLike
Filtered views enforce security. If your security model is huge and complicated (and especially if it involves lots of teams in different BUs, and/or lots of sharing), then this will be slower. So make sure to get your security model as streamlined as possible, for performance benefits in all areas.
You forgot to mention that filtered views are very denormalised, so for example in the FilteredAccounts view, the Primary Contact uses two columns – one for the GUID and one for the name. If all you need is the name, you don’t need an extra join (although of course that join has already been done in the background – this is not a performance benefit, just a simplicity of querying/reporting one). Likewise option sets, bit fields show values and labels.
This denormalisation involves lots of joins, especially on “big” entities such as Account and Contact with lots of lookups, addresses and so on. So if you are not using those lookup fields, but just want data from the base or extension tables, it can be tempting to ditch the overhead of those joins and go to the tables rather than the views. But that is probably a bad idea. Better ideas include mirroring data to a separate DB to do complex reporting without impacting the transactional DB.
The base and extension tables are merged if you do an in-place upgrade to CRM 2013, or when you do a migration and import a CRM 2011 database to 2013. If you do a migration you can set a registry key to defer this table merging, and then do them one (or several) entities at a time until they are all done.
When you upgrade to 2015, the tables are merged if they have not been done already – so do them already in 2013 to take out some risk, and speed up the process.
The filteredviews are unaffected by this change. Any reports using the extension tables directly will break when they are merged.
Merging the tables gives some significant performance gains (I am told, and it makes sense that it reduces numbers of joins).
LikeLike
Thanks for you detailed reply, I hadn’t fully considered the effects of the security model but I did have an inkling this was the main cause of any speed issues with Filtered Views.
I mentioned the two tables because filtered views use to merge them. It also shows the danger of writing reports directly against the CRM tables because they can change or disappear!
Thanks for clearing up the merging of tables in CRM 2015
Your comment reminds me you should definitely write more blog posts, you have added a lot detail and knowledge to this blog post
LikeLike
The line is wrong :You can read more about why you should create unsupported changes here.
It should be: You can read more about why you should not create unsupported changes here
LikeLike
thanks for spotting that, it has been changed
LikeLike
RE: “In CRM 2013 (optional)/CRM 2015 (mandatory) the two database table structure was changed and merged into one database table.”
In an excel based report I was using some VBA code to retrieve attributes from a few Filtered tables in CRM4.0. This still works in our CRM2015, however, the custom attributes are not returned, only the built-in attributes. Do you have any idea why?
LikeLike
The filtered views should be the same because its a view maintained by Microsoft, changes in the underlying database shouldn’t matter.
Filtered views do use the security of the user so check the privileges for the user are ok
LikeLike
Reblogged this on You Knew This.
LikeLike
Hello Hosk,
In CRM 2011 two views are available for each entity i.g. “Quote” and “FilteredQuote”.
The execution time when using the filtered view is 10x slower than the normal view.
So why not use the normal view instead of the filtered one, knowing that the normal view will still be available even after CRM 2011 and the Base and Extension tables being merged ?
LikeLike
filteredviews are used in reports because they include security of a user and they merge the base and extension tables. I guess its for the security
LikeLike
Hi,
We are migrating from CRM 2011 to CRM 2013 and we have lots of SSRS report and we don`t know in how many reports we are using ExtensionTable. Is there any way to find out the specific reports?
Thanks,
Jaspreet
LikeLike
Hi,
We are migrating from CRM 2011 to CRM 2013 and we have lots of SSRS report and we don`t know in how many reports we are using ExtensionTable. Is there any way to find out the specific reports?
Thanks,
Jaspreet
LikeLike
Hi
This is the reason you should use filtered queries which join the tables for you and would still work after upgrading.
unfortunately there is not easy way
I would check to see if they still work in CRM 2013.
You could manually check the reports
set an SQL trace, run the reports to check for extension queries.
You could parse the files the report files and see if you were retrieving from the extension tables.
LikeLike
relation slow CRM?
Using FilteredViews, issues performance CRM: errors timeout
https://community.dynamics.com/crm/f/117/t/258407
https://sqlperformance.com/2017/08/t-sql-queries/multi-statement-tvfs-dynamics-crm
https://softchief.com/2016/08/08/deal-with-slow-performed-crm/
https://support.microsoft.com/en-us/help/955138/you-experience-slow-performance-or-timeouts-when-you-try-to-access-som
https://crmbusiness.wordpress.com/2015/07/01/stopping-infinite-plugins-with-parameters-depth-and-parentcontext/
https://community.dynamics.com/crm/b/crmbusiness/archive/2015/07/01/crm-plugins-stopping-infinite-loops-and-understanding-pluginexecutioncontext-depth
https://blogs.msdn.microsoft.com/crm/2009/08/04/viewing-all-crm-privileges-including-hidden-privileges/
https://www.sqlskills.com/blogs/paul/wait-statistics-or-please-tell-me-where-it-hurts/
LikeLike