denormalization

What is a good way to denormalize a mysql database?

自古美人都是妖i 提交于 2019-11-30 11:05:32
I have a large database of normalized order data that is becoming very slow to query for reporting. Many of the queries that I use in reports join five or six tables and are having to examine tens or hundreds of thousands of lines. There are lots of queries and most have been optimized as much as possible to reduce server load and increase speed. I think it's time to start keeping a copy of the data in a denormalized format. Any ideas on an approach? Should I start with a couple of my worst queries and go from there? I know more about mssql that mysql, but I don't think the number of joins or

Clarification On Firebase Denormalization Blog Post

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 08:52:37
I just read the Firebase blog post titled Denormalizing Your Data Is Normal , and I have request for clarification. I was with it until the Considerations paragraph. Specifically, the following: "Modification of comments is easy: just set the value of the comment under /comments to the new content. For deletion, simply delete the comment from /comments — and whenever you come across a comment ID elsewhere in your code that doesn’t exist in /comments, you can assume it was deleted and proceed normally" For modifications, why don't I have to modify the duplicate comments stored under /links and

Django: How to access original (unmodified) instance in post_save signal

六眼飞鱼酱① 提交于 2019-11-28 18:13:12
I want to do a data denormalization for better performance, and put a sum of votes my blog post receives inside Post model: class Post(models.Model): """ Blog entry """ author = models.ForeignKey(User) title = models.CharField(max_length=255) text = models.TextField() rating = models.IntegerField(default=0) # here is the sum of votes! class Vote(models.Model): """ Vote for blog entry """ post = models.ForeignKey(Post) voter = models.ForeignKey(User) value = models.IntegerField() Ofcourse, I need to keep Post.rating value actual. Nornally I would use database triggers for that, but now I've

Can SQLAlchemy events be used to update a denormalized data cache?

蹲街弑〆低调 提交于 2019-11-28 18:02:38
For performance reasons, I've got a denormalized database where some tables contain data which has been aggregated from many rows in other tables. I'd like to maintain this denormalized data cache by using SQLAlchemy events . As an example, suppose I was writing forum software and wanted each Thread to have a column tracking the combined word count of all comments in the thread in order to efficiently display that information: class Thread(Base): id = Column(UUID, primary_key=True, default=uuid.uuid4) title = Column(UnicodeText(), nullable=False) word_count = Column(Integer, nullable=False,

Storing multiple choice values in database

余生长醉 提交于 2019-11-28 11:43:49
Say I offer user to check off languages she speaks and store it in a db. Important side note, I will not search db for any of those values, as I will have some separate search engine for search. Now, the obvious way of storing these values is to create a table like UserLanguages ( UserID nvarchar(50), LookupLanguageID int ) but the site will be high load and we are trying to eliminate any overhead where possible, so in order to avoid joins with main member table when showing results on UI, I was thinking of storing languages for a user in the main table, having them comma separated, like "12

Denormalize nested structure in objects with symfony 2 serializer

岁酱吖の 提交于 2019-11-28 09:10:44
I'm working on Symfony 2 project with version 2.8 and I'm using the build-in component Serializer -> http://symfony.com/doc/current/components/serializer.html I have a JSON structure provided by a web service. After deserialization, I want to denormalize my content in objects. Here is my structure (model/make in a car application context). [{ "0": { "id": 0, "code": 1, "model": "modelA", "make": { "id": 0, "code": 1, "name": "makeA" } } } , { "1": { "id": 1, "code": 2, "model": "modelB", "make": { "id": 0, "code": 1, "name": "makeA" } } }] My idea is to populate a VehicleModel object wich

Clarification On Firebase Denormalization Blog Post

南笙酒味 提交于 2019-11-28 02:17:17
问题 I just read the Firebase blog post titled Denormalizing Your Data Is Normal, and I have request for clarification. I was with it until the Considerations paragraph. Specifically, the following: "Modification of comments is easy: just set the value of the comment under /comments to the new content. For deletion, simply delete the comment from /comments — and whenever you come across a comment ID elsewhere in your code that doesn’t exist in /comments, you can assume it was deleted and proceed

How to use foreign keys with PHP

那年仲夏 提交于 2019-11-28 00:41:10
问题 So I understand how to create foreign keys and I know what is the purpose of the FK. But I have a problem in understanding How to use them. I asked a question regarding Foreign keys HERE(Click link) Here is what I made: CREATE TABLE user( id INT(11) NOT NULL AUTO_INCREMENT, username VARCHAR(50) NOT NULL, password VARCHAR(20) NOT NULL, PRIMARY KEY (id) ); CREATE TABLE items( i_id INT(11) NOT NULL AUTO_INCREMENT, name TINYTEXT NOT NULL, price DECIMAL(8,2) NOT NULL, PRIMARY KEY (i_id) ); CREATE

Django: How to access original (unmodified) instance in post_save signal

自作多情 提交于 2019-11-27 10:46:34
问题 I want to do a data denormalization for better performance, and put a sum of votes my blog post receives inside Post model: class Post(models.Model): """ Blog entry """ author = models.ForeignKey(User) title = models.CharField(max_length=255) text = models.TextField() rating = models.IntegerField(default=0) # here is the sum of votes! class Vote(models.Model): """ Vote for blog entry """ post = models.ForeignKey(Post) voter = models.ForeignKey(User) value = models.IntegerField() Ofcourse, I

In what way does denormalization improve database performance?

老子叫甜甜 提交于 2019-11-27 10:06:07
I heard a lot about denormalization which was made to improve performance of certain application. But I've never tried to do anything related. So, I'm just curious, which places in normalized DB makes performance worse or in other words, what are denormalization principles? How can I use this technique if I need to improve performance? ewernli Denormalization is a time-space trade-off. Normalized data takes less space, but may require join to construct the desired result set, hence more time. If it's denormalized, data are replicated in several places. It then takes more space, but the desired