imscp | i-MSCP Main Repository
kandi X-RAY | imscp Summary
kandi X-RAY | imscp Summary
i-MSCP Main Repository
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Load config file
- Update plugin data .
- Get CPU information
- Validate plugin info
- Updates the domain in the given client .
- Prepare mail data .
- Migrate database .
- Handles uncaught exceptions .
- Parse a gettext part
- Get the update info
imscp Key Features
imscp Examples and Code Snippets
Community Discussions
Trending Discussions on imscp
QUESTION
Question
Can a data transfer object (DTO) reference a value object (VO) of the domain model?
Context
In my domain, I've an importer which import aggregates from a collection. The collection is made of DTO build by a collector on which the importer rely. Since both the importer and collector are services (interfaces) of my domain, can the DTO reference domain value objects, or should I stick with primitives and turn them into value objects only when processing the collection (build of aggregates)?
Collector implementation where DTO made of value objects from the domain model are built
...ANSWER
Answered 2019-Aug-06 at 13:16Can a data transfer object (DTO) reference a value object (VO) of the domain model?
Yes, but you want to be very careful about doing that.
A data transfer object is, at its core, a message. For a message to serve its purpose, both the sender and the receiver must have compatible understandings of its semantics. Making an incompatible change to the DTO schema requires corresponding changes to the receiver.
A value object, in the domain model, is not a message. It is structured information, purely an implementation detail of the current model. If we want to deploy a new version of our model, which uses a completely different arrangement of values, or their underlying data structures, then we can.
So having a DTO (which is supposed to be stable) depend on a value object (which does not promise to be stable) is creating an opportunity for problems down the road.
In cases where your vocabulary of values is stable, then the risks are lower.
QUESTION
I've a simple table where we store traffic data:
...ANSWER
Answered 2017-Oct-27 at 16:40When you have the EXPLAIN that ignores the index, it shows it runs a table scan (type: ALL). The rows examined is ~4.1m (which is only a rough estimate anyway, not an accurate count).
You clarified that there are ~4.1m rows with domain_id = 150. So, practically every row in the table matches your WHERE condition.
Think of an index at the back of a book. Why doesn't it contain entries for words like "the" or "and"? Because those words appear on virtually every page, and it would be a waste of time to index them, and to use the index to find occurrences of those common words, flip to the respective page, then flip back to the index to find the next occurrence is on page 2, and so on.
It's the same way with a secondary index in MySQL. If the optimizer detects that a given value you search for is too common, it skips the index and just does a table-scan. It's easier to do that when reading an index when the index won't effectively narrow down the search enough to make it worthwhile.
In practice, I've observed that the optimizer skips using the index when the value occurs on 21-25% of rows in the table. Usually this is a good call. Rarely, it's necessary to use FORCE INDEX to tell the optimizer that you don't want a table-scan at all costs. But that's rare.
My advice is: Let the optimizer do its job. It will usually make a good decision about whether to use an index, based on the query logic and the frequency of the specific value you're searching for.
Re your comment:
If your production data allows the WHERE condition to select a minority subset of your table, then the optimizer should decide that it's worth using the index. One of the optimizer's goals is to reduce the number of examined rows that InnoDB needs to read.
This is a good example of why you need to test with data that mimics your production data. Having the right ratios of different data values helps you do a realistic query optimizer tests.
Also make sure you use ANALYZE TABLE from time to time to make sure InnoDB has current stats about data distribution in the index. I've seen cases where odd index behavior was fixed very simply by running ANALYZE TABLE. It's a quick operation, even if your table is very large.
This doesn't have to be very frequent, but if the distribution of values in your index changes dramatically (like if you do a major bulk insert or bulk delete), it's worth doing ANALYZE TABLE afterwards.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install imscp
Devuan
Ubuntu
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page