r/SQLServer • u/DataFracking • 23h ago
Community Share Wire level caching solution for SQL Server - Change Tracking Mode
Hey, I've posted before on some of my custom TDS listener stuff. All custom TDS wire protocol in c#. I think this one is probably my most useful one so far.
Here's a quick demo for anyone interested.
Full Open Source Code (MIT): https://github.com/TroBeeOne/DaffyZoom
Nuget Install and Instructions: https://www.nuget.org/packages/Daffyzoom
Hour long podcast (Ai made it for me) on how it works: https://www.youtube.com/watch?v=mwMDmuLjCCY
What it does
- It solves the problem of 1000+ repeated slow queries that are hitting stale tables. It also helps you identify those slow queries so you can 'actually fix' the indexes, plans, the proper way.
- Sits on the wire in-between client and SQL server
- On the return from SQL Server message it tee's the call, one sync back to client, another async to my caching system. If a repeat query (above 5 second default setting) if tables haven't changed, it now returns instant cache, 0 seconds. if table changed? it reruns the 7 second query and updates the cache on the way back..
- I have data warehouse mode, ttl, just caches everything repeated. with expiration.
- I have change tracking mode (this is the demo I'm showing today). This caches unless a change is made, then it runs the query as normal and refreshes cache.
- Change Tracking Mode requires change tracking enabled on target tables for repeated query. You might think, well, we're now hitting SQL Server 2 times? Yes, but the check is a microsecond. And if you're serving cache from a 10 second query instantly, and ppl are hitting that report at 8am 1000 times, you saved some compute time and made your clients super happy!
- I DO support Entra Service Credentials, but I do not support MFA. I also don't support kerberos yet, I could, but that would require me setting up a domain controller VM, and with little interest so far, no incentive.
Anyway, I haven't tested this in a major production environment yet, so if you do choose to try it, as with anything, test it well and let me know if you find issues.
Here's the demo, cheers. If you try it and run into questions or have issues, let me know.
1
u/DataFracking 36m ago
I also pushed my DaffyTee and DaffyDB applications to github. DaffyDB is a TDS Proxy for DuckDB that translates T-SQL. It contains DaffySQL with is a custom SQL Server extension for .NET for DuckDB. DaffyTee is a workload recorder (full, everything)) and debugging utility for SQL Server. https://github.com/TroBeeOne/DaffyTee and https://github.com/TroBeeOne/DaffyDB