-
-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggestion to speed up the casting of values #737
Comments
I like idea clearly separate type casting "db → php" and "php → db". May be split typecast class to two classes:
These classes should be placed in DB implementations packages and uses into Also has idea create classes for each column types. In this case type casting should be implemented into this clasess. |
Also thought about this, looks better 👍
👍 Sure, this is just an example. |
Realized example of creating classes for each column type with optimization of Results for
|
Suggestion to predefine cast methods in a separate class (e.g.
Typecast
)https://github.com/Tigrov/db-pgsql/blob/speedup_typecast_predefined/src/Typecast.php
Then initialize the predefined methods in
ColumnSchema
objectshttps://github.com/Tigrov/db-pgsql/blob/speedup_typecast_predefined/src/Schema.php#L819
And use the predefined methods when casting values
https://github.com/Tigrov/db-pgsql/blob/speedup_typecast_predefined/src/ColumnSchema.php#L84
https://github.com/Tigrov/db-pgsql/blob/speedup_typecast_predefined/src/ColumnSchema.php#L131
This increase the speed of casting values by an average of 30-40%
More information and benchmarks
https://github.com/Tigrov/db-pgsql/tree/speedup_typecast_predefined
Update:
If
phpTypecast()
casts values retrieved from DB only, some checks can be removed, this will increase the speed by 10-20% more.The text was updated successfully, but these errors were encountered: