Home Page
Projects > GoFasterSql
Search:
GoFasterSql Thumbnail
GoFasterSql v1.2.1
Completed
GoFasterSQL is a tool designed to enhance the efficiency and simplicity of scanning SQL rows into structures.
Rating: 10 (Fixes a number of native problems when dealing with SQL in GoLang)
Project Time: 12/14/2023-1/23/2024: 60
Languages: MySQL, GoLang
Requirements:
Downloads: Source (See any updates below for prior versions)
Sections: Information, Content, Concepts, Updates, Comments
Information

The flaw in the native library scanning process is its repetitive and time-consuming type determination for each row scan. It must match each field’s type with its native counterpart before converting the data string (byte array). Furthermore, the requirement to specify each individual field for scanning is tedious.


GoFasterSQL instead precalculates string-to-type conversions for each field, utilizing pointers to dedicated conversion functions. This approach eliminates the need for type lookups during scanning, vastly improving performance. The library offers a 2 to 2.5 times speed increase compared to native scan methods (5*+ vs sqlx), a boost that varies with the number of items in each scan. Moreover, its automatic structure determination feature is a significant time-saver during coding.


See the github page for full documentation.


Content
Gol10n logo

The library’s ModelStruct function, upon its first invocation for a list of types, determines the structure of those types through recursive reflection. These structures are then cached, allowing for swift reuse in subsequent calls to ModelStruct. This process needs to be executed only once, and its output is concurrency-safe.

ModelStruct flattens all structures and records their flattened member indexes for reading into; so row scanning is by field index, not by name. To match by name, use a RowReaderNamed via StructModel.CreateReaderNamed() (See example #2 in github documentation).

RowReaders, created via StructModel.CreateReader(), are not concurrency safe and can only be used in one goroutine at a time.

Concepts
Databases, Optimization, Code Organization
Updates
GoFasterSQL v1.2.1 - Overhaul of null types system @ 2024-04-15 14:17:37 - Download
The nulltypes system has been overhauled so all null types are under a generic type named NullType in the top level package. For example, instead of using nulltypes.NullUint8 you would now use NullType[uint8]. This also really helped clean up the null types code. This is a version breaking change, hence the minor version number update.

Other minor changes:
  • Readme file and package information has been updated with the following changes:
    • The type support section has been redone for clarity
    • The structs in the code examples have had the members labeled to explain their used supported type
  • Marshled JSON strings are now properly json escaped
  • Added bypass for my RawBytes bug fix, now that it has been fixed in go v1.23
  • Removed test case that is no longer compatible with go 1.21+
GoFasterSql project added @ 2024-03-16 06:07:33 - Download

GoFasterSQL is a tool designed to enhance the efficiency and simplicity of scanning SQL rows into structures in Go[lang].

While this project was first released in December of 2023 on github and has already had 7 releases there, I’ve finally gotten around to adding it here. I don’t anticipate there being many more releases any time soon as the project is feature complete.

Comments
To add comments, please go to the forum page for this project (guest comments are allowed for the Projects, Posts, and Updates Forums).
Comments are owned by the user who posted them. We accept no responsibility for the contents of these comments.

No comments for this Project