Jaxel
Well-known member
Indexing has always been something a bit hard to figure out. Indexing trades a performance hit during database writes, in order to improve performance during database reads. It has always been my understanding, that any columns which you would use in a 
Prime example would be my XenAtendo addon. The
	
	
	
		
Naturally, I would want to define
But then I think about all the possible search queries I would want to include in this system:
				
			WHERE clause should be indexed. But I often find myself wondering about excessive uses of indexes...Prime example would be my XenAtendo addon. The
events table of this addon is as follows:
		Code:
	
	            $table->addColumn('user_id',                 'int', 10);
            $table->addColumn('username',                'varchar', 100);
            $table->addColumn('thread_id',                'int', 10);
            $table->addColumn('event_id',                'int', 10)->autoIncrement();
            $table->addColumn('event_date',                'int', 10);
            $table->addColumn('event_repeat',            'varchar', 50);
            $table->addColumn('event_state',            'enum')->values(['visible', 'moderated']);
            $table->addColumn('event_title',            'varchar', 255);
            $table->addColumn('event_description',        'mediumtext');
            $table->addColumn('event_location',            'varchar', 255);
            $table->addColumn('event_address',            'varchar', 255);
            $table->addColumn('event_latitude',            'double');
            $table->addColumn('event_longitude',        'double');
            $table->addColumn('event_geocode',            'blob');
            $table->addColumn('event_rsvp',                'int', 1);
            $table->addColumn('event_featured',            'int', 1);Naturally, I would want to define
event_id as the primary key... one index down. Then for collision sake, I would want to define thread_id as a unique key, because a thread can only be linked to one event... two indexes down.But then I think about all the possible search queries I would want to include in this system:
- user_id- search for events from a single user
- event_date- search for events created after certain dates
- event_state- search for events states for moderation purposes
- event_latitude- search for events based on their location
- event_longitude- search for events based on their location
- event_featured- search for events which are marked as featured
 
 
		 
 
		
 
 
		 
 
		 
 
		 
 
		