aggregate

Efficiently querying a huge time series table for one row every 15 minutes

ⅰ亾dé卋堺 提交于 2019-12-18 18:00:50
问题 I have two tables, conttagtable (t) and contfloattable (cf). T has about 43k rows. CF has over 9 billion. I created an index on both tables on the tagindex column on both tables. This column can be thought of as a unique identifier for conttagtable and as a foreign key into conttagtable for confloattable . I didn't explicitly create a PK or foreign key on either table relating to the other, although this data is logically related by the tagindex column on both tables as if conttagtable

DDD - how to rehydrate

断了今生、忘了曾经 提交于 2019-12-18 16:58:49
问题 Question : what is the best, efficient and future proof way to rehydrate an aggregate from a repository? What are the pro's and con's of the provided ways and are my perceptions correct? Let's say we have an Aggregate Root with private setters but public getters for accessing state Behaviour is done through methods on the aggregate root. A repository is instructed to load an aggregate. At the moment I see a couple of possible ways to achieve this: set the state through reflection (manual or

DDD - how to rehydrate

我与影子孤独终老i 提交于 2019-12-18 16:58:32
问题 Question : what is the best, efficient and future proof way to rehydrate an aggregate from a repository? What are the pro's and con's of the provided ways and are my perceptions correct? Let's say we have an Aggregate Root with private setters but public getters for accessing state Behaviour is done through methods on the aggregate root. A repository is instructed to load an aggregate. At the moment I see a couple of possible ways to achieve this: set the state through reflection (manual or

NHibernate QueryOver select entity and aggregates

只谈情不闲聊 提交于 2019-12-18 16:54:55
问题 What I want to do is display a simple grid of data which contains the entity data, and the aggregate data of its children. For example lets use a Order and line items. I want to display the order information, and the count of line items. OrderID, OrderDate, NumOfLineItems Now normally in SQL you can do it many ways. But this is the only way I could think of that might work when translating to NHibernate. SELECT o.OrderID, OrderDate, NumOfLineItems FROM #Orders o INNER JOIN (SELECT o2.OrderID,

R stacked barchart with aggregate data

心不动则不痛 提交于 2019-12-18 16:25:32
问题 I'm having troubles creating a stacked barchart with aggregate data. When dealing with aggregate tables from other people's reports I generally use Excel, but I'd like to start doing all my charts in R, possibly with lattice or ggplot. In Excel doing a stacked barchart of the following aggregate data takes a couple of clicks (Insert, Column Charts, Stacked Column), and you get something like this. . Besides wanting to this chart in R I also want to use ggplot's faceting,i.e. put two stacked

How to prefetch aggregated @property in Django?

左心房为你撑大大i 提交于 2019-12-18 13:39:32
问题 We have two models (simplified versions): class Contestant(models.Model): email = models.EmailField(max_length=255, unique=True) # plus some other fields @property def total_points(self): return self.points.aggregate(total=Sum('value'))['total'] or 0 class Points(models.Model): contestant = models.ForeignKey(Contestant, related_name='points') value = models.PositiveIntegerField() # plus some other fields which determine based on what we # awarded ``Points.value`` When we display a list of

DDD: Aggregate Roots

泪湿孤枕 提交于 2019-12-18 11:35:59
问题 I need help with finding my aggregate root and boundary. I have 3 Entities: Plan, PlannedRole and PlannedTraining. Each Plan can include many PlannedRoles and PlannedTrainings. Solution 1: At first I thought Plan is the aggregate root because PlannedRole and PlannedTraining do not make sense out of the context of a Plan. They are always within a plan. Also, we have a business rule that says each Plan can have a maximum of 3 PlannedRoles and 5 PlannedTrainings. So I thought by nominating the

T-SQL GROUP BY: Best way to include other grouped columns

烂漫一生 提交于 2019-12-18 11:28:48
问题 I'm a MySQL user who is trying to port some things over to MS SQL Server. I'm joining a couple of tables, and aggregating some of the columns via GROUP BY. A simple example would be employees and projects: select empID, fname, lname, title, dept, count(projectID) from employees E left join projects P on E.empID = P.projLeader group by empID ...that would work in MySQL, but MS SQL is stricter and requires that everything is either enclosed in an aggregate function or is part of the GROUP BY

Count totals by year and month

只谈情不闲聊 提交于 2019-12-18 11:09:56
问题 I have a table that looks like this: id,created,action 1,'2011-01-01 04:28:21','signup' 2,'2011-01-05 04:28:21','signup' 3,'2011-02-02 04:28:21','signup' How do I select and group these so the output is: year,month,total 2011,1,2 2011,2,1 回答1: Try this: SELECT DATE_FORMAT(created, '%Y') as 'year', DATE_FORMAT(created, '%m') as 'month', COUNT(id) as 'total' FROM table_name GROUP BY DATE_FORMAT(created, '%Y%m') 回答2: SELECT YEAR(created) as year_val, MONTH(created) as month_val ,COUNT(*) as

Elasticsearch - generic facets structure - calculating aggregations combined with filters

 ̄綄美尐妖づ 提交于 2019-12-18 10:32:11
问题 In a new project of ours, we were inspired by this article http://project-a.github.io/on-site-search-design-patterns-for-e-commerce/#generic-faceted-search for doing our “facet” structure. And while I have got it working to the extent the article describes, I have run into issues in getting it to work when selecting facets. I hope someone can give a hint as to something to try, so I don’t have to redo all our aggregations into separate aggregation calculations again. The problem is basically