Saturday, November 17, 2018
Wednesday, November 14, 2018
Database : Single-column index vs. multicolumn index
The two types of indexes are single-column indexes and multicolumn indexes. A single-column index is an index based on the values in one column of a table. A multicolumn index is an index based on the values in multiple columns of a table.
- Organization of this subsection
- (1) Creating a single-column index
- (2) Creating a multicolumn index
(1) Creating a single-column index
A single-column index should be created when retrieval will be executed using one column only as the key.
(2) Creating a multicolumn index
A multicolumn index should be created in the cases discussed below.
http://itdoc.hitachi.co.jp/manuals/3020/3020635200e/W3520279.HTM#ID00988
(a) Retrieval of data that satisfies multiple conditions
A multicolumn index should be created when data satisfying multiple conditions is to be retrieved, such as when a complex-condition retrieval using the AND operator with multiple columns as the key is executed.http://itdoc.hitachi.co.jp/manuals/3020/3020635200e/W3520279.HTM#ID00988
Database : Guidelines for Application-Specific Indexes
You can create indexes on columns to speed up queries. Indexes provide faster access to data for operations that return a small portion of a table's rows.
In general, you should create an index on a column in any of the following situations:
- The column is queried frequently.
- A referential integrity constraint exists on the column.
- A
UNIQUE
key integrity constraint exists on the column.
You can create an index on any column; however, if the column is not used in any of these situations, creating an index on the column does not increase performance and the index takes up resources unnecessarily.
Although the database creates an index for you on a column with an integrity constraint, explicitly creating an index on such a column is recommended.
You can use the following techniques to determine which columns are best candidates for indexing:
- Use the
EXPLAIN PLAN
feature to show a theoretical execution plan of a given query statement. - Use the
V$SQL_PLAN
view to determine the actual execution plan used for a given query statement.
Sometimes, if an index is not being used by default and it would be most efficient to use that index, you can use a query hint so that the index is used.
Monday, November 12, 2018
Thursday, November 8, 2018
CakePHP : Implementing the Repository Pattern with CakePHP
Implementing the Repository Pattern with CakePHP
I’ve long professed how I dislike convoluted controllers. CakePHP’s find method almost immediately causes this when used inside a controller. More importantly, the code inside the find method is extremely unreadable. This is almost more important than a large controller function!
This is where the repository pattern comes in. At its most basic example (which some will consider overkill – you know who you are), I still think the repository pattern is clearer.
Here is an example using the regular find approach:
$user = $this->User->find('first', array('conditions' => array('id' => $id)));
Compared to a repository example:
$user = $this->UserRepository->GetById($id);
The code is almost identically; however, in the second example, it’s clear that if I were to “read” the code I am retrieving a user by id opposed to I’m finding the first user with the conditions of id being equal to the variable $id.
http://www.endyourif.com/implementing-the-repository-pattern-with-cakephp/
OOP : Traits
Summary: in this tutorial, you will learn how to use PHP traits to share functionality across independent classes, which are not in the same inheritance hierarchy.
Introduction to PHP traits
Code reuse is one of the most important aspects of object-oriented programming. In PHP, you use inheritance to enable code reuse in different classes that share the same inheritance hierarchy. To achieve code reuse, you move the common functionality of classes to method of the parent class. Inheritance makes the code very tightly coupled therefore makes the code hard to maintain.
To overcome this problem, as of version 5.4.0, PHP introduced a new unit of code reuse named
trait
.Traits allow you to reuse a set of methods freely in many different classes that does not need to be in the same class hierarchy.
Trait is similar to class but it is only for grouping methods in a fine-grained and consistent way. It is not allowed to instantiate a trait on its own.
http://www.zentut.com/php-tutorial/php-traits/
http://www.zentut.com/php-tutorial/php-traits/
Subscribe to:
Posts (Atom)
-
In today’s software development landscape, APIs (Application Programming Interfaces) are essential for enabling communication between differ...
-
Vuetify is a popular UI framework for Vue apps. In this article, we’ll look at how to work with the Vuetify framework. Color Picker Inputs W...
-
https://www.positronx.io/build-secure-php-rest-api-in-laravel-with-sanctum-auth/