Sift Tables

NavStudent
Member Posts: 399
Hello I was reading this column on persisted columns on sql 2k5.
This looks like a solution for sift tables.
You could instead of sift table use persisted fields.
Anybody ever thought about this?
Here is an example
In navsion world the nonclustered index would be [invoice no,Invoice_Total] . And the persistant field will equal the actual field instead of adding two fields. That way summing up on the value is done on the key, and not on the data. That way you don't need sift tables at all.
:-k
Here is an article about this.
http://www.sql-server-performance.com/bm_adding_indexes_persisted.asp
This looks like a solution for sift tables.
You could instead of sift table use persisted fields.
Anybody ever thought about this?
Here is an example
CREATE TABLE [dbo].[Invoice_Table]( [Invoice#] [int] IDENTITY(1,1) NOT NULL, [Invoice_Amount] [money] NOT NULL, [Invoice_Freight] [money] NOT NULL, [Invoice_Total] AS ([Invoice_Amount]+[Invoice_Freight]) PERSISTED ) ON [PRIMARY] CREATE NONCLUSTERED INDEX [Invoice_Total_Idx] ON [dbo].[Invoice_Table] ( [Invoice_Total] ASC ) ON [PRIMARY]
In navsion world the nonclustered index would be [invoice no,Invoice_Total] . And the persistant field will equal the actual field instead of adding two fields. That way summing up on the value is done on the key, and not on the data. That way you don't need sift tables at all.
:-k
Here is an article about this.
http://www.sql-server-performance.com/bm_adding_indexes_persisted.asp
my 2 cents
0
Comments
-
Hello Navstudent.
I ran test on this on sql and running a sum statement on PERSISTED fields is slower than the actual fields.
Here are the steps I took.
In First statement I created the table. with the key.CREATE TABLE [dbo].[Invoice_test]( [Invoice] [int] IDENTITY(1,1) NOT NULL, [Invoice_Amount] [money] NOT NULL, [Invoice_Total] AS ([Invoice_Amount]) PERSISTED ) ON [PRIMARY] CREATE NONCLUSTERED INDEX [Invoice_Total_Idx] ON [dbo].[Invoice_test] ( [Invoice], [Invoice_Total] ASC ) ON [PRIMARY]
Then I populated the tabel with 100K random recordsdeclare @t int set @t=1000 while @t <= 100000 begin insert [Invoice_test] (Invoice_Amount) values (rand()*26 + 65) select @t=@t + 1 end go
Ran the following statement to sum on actual field.DBcC dropcleanbuffers dbcc freeproccache GO select sum(Invoice_Amount) AS INVOICE from Invoice_test where Invoice > 50000 and Invoice < 60000 go
This took 400 ms.
Then I ranDBcC dropcleanbuffers dbcc freeproccache select sum(Invoice_Total) AS INVOICETOTAL from Invoice_test where Invoice > 40000 and Invoice < 50000
This took 183 milliseconds. Almost in half.
hmmmm
I'll next create a navision table and will post the results. I'm doubt sift table will be slower.0 -
I ran some more test., by creating a clustered key on the table update statistic etc on the table
The results are now the opposite. Persisted field take longer than actual fields. About 2 and half times longer than the actual fields.
Hope this answers your question.0 -
[Topic moved from Navision forum to SQL Performance forum]Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions