{"title":"Data Access","url":"https://jonas-paprotka.de/docs/dev-itpro/administration/optimize-sql-data-access/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/administration/optimize-sql-data-access, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/administration/optimize-sql-data-access","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Learn how to improve data access performance in Business Central.","date":"2022-03-03","meta":{"topic":"article"},"outline":[{"level":2,"title":"Business Central Server data caching","slug":"business-central-server-data-caching","at":503,"chars":2041},{"level":2,"title":"Business Central Server connections to SQL Server","slug":"business-central-server-connections-to-sql-server","at":2544,"chars":1247},{"level":2,"title":"Data read/write performance","slug":"data-readwrite-performance","at":3791,"chars":1644},{"level":2,"title":"Default SQL constraints on columns","slug":"default-sql-constraints-on-columns","at":5435,"chars":896},{"level":3,"title":"Default constraint value","slug":"default-constraint-value","at":5758,"chars":573},{"level":2,"title":"Related information","slug":"related-information","at":6331,"chars":147}],"text":"Data that is needed in the client goes through the following path from the Business Central Server to the SQL Server database:\n1. If the data is cached in the Business Central Server data cache, it's returned.\n2. If the data isn't cached in the Business Central Server data cache, it's fetched from SQL Server over the network as follows:\n 1. If the data resides in SQL Servers data cache, it's returned.\n 2. If the data doesn't reside in SQL Servers data cache, it's fetched from storage and returned.\n## Business Central Server data caching\nIn Business Central, the data cache is shared by all users who are connected to the same Business Central Server instance. So, after one user has read a record, a second user who reads the same record gets it from the cache.\nThe following AL methods use the cache system:\n GET\n GETBYSYSTEMID\n FIND\n FINDFIRST\n FINDLAST\n FINDSET\n COUNT\n ISEMPTY\n CALCFIELDS\nThere are two types of caches, global and private:\n Global cache is for all users connected to a Business Central Server instance.\n Private cache is per user, per company, in a transactional scope. Data in a private cache for a given table and company is flushed when a transaction ends.\nThe cache that is used is determined by the lock state of a table. If a table isn't locked, then the global cache is queried for data; otherwise, the private cache is queried.\nResults from query objects aren't cached.\nFor a call to any of the FIND functions, 1024 rows are cached. You can set the size of the cache by using the Data Cache Size setting in the Business Central Server configuration file. The default size is 9, which approximates a cache size of 500 MB. If you increase this number by one, then the cache size doubles.\nYou can bypass the cache by using the ../developer/methods-auto/database/database-selectlatestversion-method.\nBusiness Central synchronizes caching between Business Central Server instances that are connected to the same database. By default, the synchronization occurs every 30 seconds.\nYou can set the cache synchronization interval by using the CacheSynchronizationPeriod parameter in the CustomSettings.config file. This parameter isn't included in the CustomSetting.config file by default, so you must add it manually using the following format:\n```\n<add key=\"CacheSynchronizationPeriod\" value=\"hh:mm:ss\" />\n```\nFor example, to set the interval to 50 seconds, set the value to `\"00:00:50\"`. For more information about the CustomSettings.config file, see Configuring Business Central Server<configure-server-instance>.\n## Business Central Server connections to SQL Server\nThe Business Central Server uses ADO.NET to connect to the SQL Server database. The ADO.NET interface is a managed data access layer that supports SQL Server connection pooling, which can dramatically decrease memory consumption by Business Central Server. SQL Server connection pooling also simplifies deployment of the Business Central three-tier architecture for deployments where the three tiers are installed on separate computers. Specifically, administrators are no longer required to manually create SPNs or to set up delegation when the client, Business Central Server, and SQL Server are on separate computers.\nThere's no longer a one-to-one correlation between the number of client connections and the number of SQL Server connections. In earlier versions of Business Central, each SQL Server connection could consume up to 40 MB of memory. Additionally, memory allocation is now in managed memory, which is more efficient than unmanaged memory.\nRecords are retrieved using Multiple Active Result Sets \\(MARS\\). methods such as NEXT, FIND\\('-'\\), FIND\\('+'\\), FIND\\('>'\\), and FIND\\('\\<'\\) are faster with MARS than the server cursors that earlier versions of Business Central used.\n## Data read/write performance\nAL functions COUNT and AVERAGE formulas can use SIFT indexes. See ../developer/methods-auto/record/record-calcsums-method and ../developer/methods-auto/record/record-calcfields-method. MIN and MAX formulas use SQL Server MIN and MAX functions exclusively.\nRecordIds and SQL Variant columns in a table don't prevent the use of BULK inserts. See optimize-sql-bulk-inserts.\nIn most cases, filtering on FlowFields issues a single SQL statement. In earlier versions of Business Central, filtering on FlowFields issued an SQL statement for each filtered FlowField and for each record in the table to calculate the filtered FlowFields. The exceptions in Business Central in which filtering on FlowFields doesn't issue a single SQL statement are as follows:\n You use the ValueIsFilter option on a field and the field has a value.\n A second predicate is specified on a source field and the field that is used for the second predicate has a value. For example, when you specify the ../developer/properties/devenv-calcformula-property for a FlowField, you can specify table filters in the Calculation Formula window. If you specify two or more filters on the same source field, then filtering doesn't issue a single SQL statement.\nIn most cases, calling the FIND or NEXT functions after you have set the view to include only marked records issues a single SQL statement. In earlier versions of Business Central, calling FIND or NEXT functions that have marked records issued an SQL statement for each mark. There are some exceptions if many records are marked. See ../developer/methods-auto/record/record-markedonly-method.\n## Default SQL constraints on columns\nTo add a default constraint to a field (column), use the following SQL statement:\n```sql\nALTER TABLE ADD CONSTRAINT constraint_name DEFAULT default_value FOR field_name\n```\nThe name of the default constraint isn't important, as long as it isn't used by another column in the database.\n### Default constraint value\nBusiness Central sets default constraints on fields in a tables. The following table list the values used for default constraints for the different data types:\nData type|value\nInteger, Option, Boolean, Byte, Duration, BigInteger|0\nDecimal|0.0\nDateFormula|''\nText|N''\nRecordId, TableFilter|0x00\nGuid, Media, MediaSet|00000000-0000-0000-0000-000000000000\nCode (Default, VarChar, Variant types)|N''\nCode (Integer, BigInteger types)|0\nTime, Date, DateTime|'1753.01.01'\n> NOTE\n> Blobs don't get default constraints, but they are allowed to be null.\n## Related information\noptimize-sql-query-objects-and-performance\nGetBySystemId(Guid)<../developer/methods-auto/record/record-getbysystemid-method>"}