sql server - Prepared data with swapping or multiple joins each time? -


Please, explain it with an example:

You need to show real information Is a customer about a product's price The final value is the way to buy customer privacy, their location, the product of the current product and the seller.

The quantity of products is above 10 billion, apart from that you should show price in different currency. And the last problem is that the seller sends a lot of prices on their products every day, so that you can apply the whole day (updated) due to a lot of positions, while the customer does not want to wait until Do not update all of you and want to know the current value (I know that it is impossible, but what do I mean - that a customer should not see such messages: "Forgive Yes, you have to wait until all prices are updated ").

What do I want

I want to split a table ThePrice (productId, vendorId, usdPrice) , Which is every time a customer creates a query, then select

  from that way .... Join thePrice p Inner vendors v ... Internal Vendors VP Price Included ... Join Internal UserRatio ur ... left  

First Aid (Product ID, Seller ID, USDPRC, SDI, User1Ratio, user2Ratio, user3Ratio, shipppingRatio, Europis, localPrice)

and

SecondPr Ice (productId, vendorId, usdPrice, user1Ratio, user2Ratio, user3Ratio, shipppingRatio, euroPrice, localPrice) .

Where

userXRatio - Multiply all possible potential level of customer privacy level on additional usdPrice . ShippingRiiteo - Defines that customers need shipping over multiplied by usdPrice . Europis , Local Value - In relation to today's quotation, the price of showing in different pices is worth.

Select which

  if (@OneHourPassed = 1) ... Select from FirstPrice ... from SecondPrice ... is not the best way, But just to indicate this,   

now re-calculates all the parameters every time, because one price can change on every next question, when it ThePirice There is no cache for the table to be updated.

This means, I get locks from time to time, because when a customer searches for the product, it is still being updated all day. Imagine - In one minute, 2000 questions can be asked from customers and one or two vendors' prices can be updated. in the same table!

I want to use ready-made data: While the first value table READ, secondpres is used for the WRITE table - To update prices and swap at a given time, that is, in one hour.

And I just want to know - what is the mechanism to implement it using IF-S? Or is there another beautiful way?

Your question also excludes a letter in space, but what can I do There is something like this that can help you.

VendorId integer, usdPrice money, user1Ratio integer, user2Ratio integer, user3Ratio integer, shipppingRatio integer, euroPrice money, localPrice money) Create Table LastExecution (execDate datetime default getdate ()); Enter the lastExecution (execDate) values ​​(default); If the LastExecution generated from GO Process SP_PRICE announced the beginning date @DATE DATETIME @ date = EXECDATE (DateDiff (hour, @ date, GETDATE ())> 0) lastExecution (execDate) values ​​(default) ) Start; Choose 'second' as 'table', * seconds; Before the end, select 'first' as 'table', * first aid; END END;

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

C++ Array Type Not Assignable in Copy Constructor -