[MDEV-5800] indexes on virtual (not materialized) columns Created: 2014-03-06  Updated: 2024-01-30  Resolved: 2016-12-13

Status: Closed
Project: MariaDB Server
Component/s: Virtual Columns
Fix Version/s: 10.2.3

Type: Task Priority: Blocker
Reporter: Sergei Golubchik Assignee: Sergei Golubchik
Resolution: Fixed Votes: 7
Labels: Compatibility, gsoc14, gsoc15

Issue Links:
Blocks
blocks MDEV-6017 Add support for Indexes on Expressions In Review
blocks MDEV-9056 JSON support Closed
PartOf
is part of MDEV-10137 Providing compatibility to other data... Open
Problem/Incident
causes MDEV-11703 InnoDB background threads show up in ... Stalled
causes MDEV-11704 InnoDB: Failing assertion: dfield_is_... Closed
causes MDEV-11710 thd_destructor_proxy() hangs on shutd... Closed
causes MDEV-11742 [Draft] InnoDB: Failing assertion: my... Closed
causes MDEV-12057 Embedded server shutdown hangs in InnoDB Closed
causes MDEV-13039 innodb_fast_shutdown=0 may fail to pu... Closed
causes MDEV-13568 gcol.innodb_virtual_debug_purge faile... Closed
causes MDEV-16887 innobase/trx/trx0rec.cc .. Assertion ... Closed
causes MDEV-18084 Server crashes in row_upd_changes_som... Closed
causes MDEV-20618 Assertion `btr_validate_index(index, ... Closed
causes MDEV-23294 Segfault or assertion upon MyISAM repair Closed
causes MDEV-29666 InnoDB fails to purge secondary index... Closed
causes MDEV-33329 ALTER TABLE...FORCE fails to recalcul... Open
Relates
relates to MDEV-11518 Assertion `!table || (!table->read_se... Closed
relates to MDEV-11526 Server crashes in in TABLE::init Closed
relates to MDEV-11540 Unexpected system threads in the proc... Closed
relates to MDEV-11541 Wrong result (extra rows) with an ind... Closed
relates to MDEV-11582 InnoDB: Failing assertion: !((field)-... Closed
relates to MDEV-11590 Server crashes in create_tmp_table / ... Closed
relates to MDEV-11591 Error: Freeing overrun buffer, Freein... Closed
relates to MDEV-11598 Assertion `!table || (!table->read_se... Closed
relates to MDEV-11604 Assertion `!check_datetime_range(ltim... Closed
relates to MDEV-11605 Assertion `(longlong) thd->status_var... Closed
relates to MDEV-11606 Server crashes in mi_make_key / sort_... Closed
relates to MDEV-11607 Server crashes in __memcpy_sse2_unali... Closed
relates to MDEV-11639 Server crashes in update_virtual_fiel... Closed
relates to MDEV-11704 InnoDB: Failing assertion: dfield_is_... Closed
relates to MDEV-11736 InnoDB: Failing assertion: n < rec_of... Closed
relates to MDEV-11737 Failing assertion: block->magic_n == ... Closed
relates to MDEV-11750 Assertion `vfield' failed in TABLE::... Closed
relates to MDEV-11754 Invalid read of size 8 in malloc_size... Closed
relates to MDEV-13795 ALTER TABLE…DROP PRIMARY KEY, ADD PRI... Closed
relates to MDEV-14046 Allow ALGORITHM=INPLACE for 10.1 tabl... Closed
relates to MDEV-16332 Allow ALGORITHM=NOCOPY or INSTANT for... Confirmed
relates to MDEV-17466 Virtual column value not available du... Closed
relates to MDEV-17468 Avoid table rebuild on operations on ... Stalled
relates to MDEV-17540 Server crashes in dict_table_get_firs... Closed
relates to MDEV-17598 InnoDB index option for per-record tr... Open
relates to MDEV-17834 Server crashes in row_upd_build_diffe... Closed
relates to MDEV-18981 Possible corruption when using FOREIG... Closed
relates to MDEV-23632 ALTER TABLE...ADD KEY creates corrupt... Closed
relates to MDEV-25047 SIGSEGV in mach_read_from_n_little_en... Closed
relates to MDEV-32089 Assertion `!strcmp(&path[strlen(path)... Stalled
relates to MDEV-11517 Confusing error message upon attempt ... Open
relates to MDEV-11561 Different handling of out-of-range va... Open
relates to MDEV-13472 rpl.rpl_semi_sync_wait_point crashes ... Closed
relates to MDEV-13671 InnoDB should use case-insensitive co... Closed
relates to MDEV-14080 InnoDB shutdown sometimes hangs Closed
relates to MDEV-14332 Corruption during online table-rebuil... Closed
relates to MDEV-15114 ASAN heap-use-after-free in mem_heap_... Closed
relates to MDEV-16222 Assertion `0' failed in row_purge_rem... Closed
relates to MDEV-17005 ASAN heap-use-after-free in innobase_... Closed
relates to MDEV-18812 Add support for generated indexed vir... Open
relates to MDEV-20015 Assertion `!in_use->is_error()' faile... Closed
relates to MDEV-22363 Reimplement the InnoDB virtual column... Open
relates to MDEV-23547 InnoDB: Failing assertion: *len in ro... Closed
relates to MDEV-31066 Aria Engine Does Not Allow Index On V... Closed
Epic Link: Oracle Compatibility
Sprint: 10.2.0-1, 10.2.0-2, 10.2.0-4, 10.2.0-6, 10.2.0-7, 10.2.0-8, 10.2.0-9, 10.2.0-10, 10.2.0-11, 10.2.2-4, 10.2.3-2, 10.0.28, 10.2.4-1, 10.2.4-4

 Description   

Currently to have a index on a virtual column, one has to materialized it. To support indexes on fully virtual columns, a storage engine must call back into the server to calculate the value of the virtual column.



 Comments   
Comment by Richa Sehgal [ 2015-03-13 ]

Hi,

I am Richa Sehgal currently pursuing Master’s at University of Illinois Urbana Champaign, USA. I did my undergraduate from Indian Institute of Technology Delhi (IIT-Delhi). I would like to take this up as my GSoC project.

Materialization gives us two things:
1. A name to the column which we can use in queries
2. A formal "regular" column which is stored and indexed in the regular fashion - Disadvantage: Extra memory requirements for the materialized column.

My initial thoughts on this project are the following:
We do need the name of the column which can be used to query. So maybe we can expose a command such as:

create virtual_index <name> on <column_name> <expression>

What this would do would run a regular query which evaluates expressions (like in WHERE clause) and the feed the result into the indexer. This index can then be stored in the regular fashion.
Am I approaching this in the right direction? Can you please point me to the next steps?
Thanks
Richa

Comment by Sergei Golubchik [ 2015-03-13 ]

https://lists.launchpad.net/maria-developers/msg08303.html

Comment by Axel Schwenke [ 2015-10-19 ]

From a user right now on #maria: an index on a virtual column should be used not only when the virtual column is referenced by name, but also when the expression defining that column is used. That would mean that an index on a virtual column is equivalent to a functional index (MDEV-6017) on the expression defining that column.

Example:

CREATE TABLE t1 (c1 INT, c2 INT, c3 INT AS (c1+c2) VIRTUAL, INDEX (c3));
SELECT * FROM t1 WHERE c3=42;
SELECT * FROM t1 WHERE (c1+c2)=42;

The expectation is that both queries use the index on the virtual column. The first because the virtual column is referenced by name, the second because the virtual column is referenced by the defining expression. The index on c3 would behave like a functional index on (c1+c2)

Generated at Thu Feb 08 07:07:09 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.