I would like to know how fast is SELECT * FROM user_table WHERE email = ‘test@gmail.com’ is this O(1) or O(n)? how does sql search for a particular row? Answer If there is no index on “email” column, the search complexity is O(N). If there was hash-based index on an “email” column, then the search could be performed in O(1).
Tag: data-structures
How to combine information from a main table and a log table in SQL Server
I currently have 2 tables in my database that i need to combine information from. One of them is a log table, that registers the status change of all products in the system. Structure example: ChangeDate Product LastStatus NewStatus 2021-10-01 A New Aging 2021-11-02 A Aging Ressuply 2021-11-25 A Ressuply OFF 2021-08-03 B New Aging 2021-09-04 B New Aging 2021-10-13
How does page overflow with columns (InnoDB) work in MySQL?
The documentation says: “Whether columns are stored off-page depends on the page size and the total size of the row.” 1.- This means that if I have a page size of 16KB, the maximum size of the row would be 8KB, therefore, if I have 4 columns, will the maximum size of each column be 2KB (approximately)? 2.- When the
Storing a huge amount of points(x,y,z) in a relational database
I need to store a very simple data structure on disk – the Point. It’s fields are just: Moment – 64-bit integer, representing a time with high precision. EventType – 32-bit integer, reference to another object. Value – 64-bit floating point number. Requirements: The pair of (Moment + EventType) is unique identifier of the Point, so I suspect it to
How to store ordered items which often change position in DB
I need to be able to store a large list of ordered items in the DB. So far that’s straight-forward: In queries, I always need to get just a few items (filtered based on OtherFields) but in the correct order. Easy as well, putting an index on Position and using “order by Position”. Now the problem: Items change their Position