Message: Return type of CI_Session_files_driver::open($save_path, $name) should either be compatible with SessionHandlerInterface::open(string $path, string $name): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Message: Return type of CI_Session_files_driver::close() should either be compatible with SessionHandlerInterface::close(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Message: Return type of CI_Session_files_driver::read($session_id) should either be compatible with SessionHandlerInterface::read(string $id): string|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Message: Return type of CI_Session_files_driver::write($session_id, $session_data) should either be compatible with SessionHandlerInterface::write(string $id, string $data): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Message: Return type of CI_Session_files_driver::destroy($session_id) should either be compatible with SessionHandlerInterface::destroy(string $id): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Message: Return type of CI_Session_files_driver::gc($maxlifetime) should either be compatible with SessionHandlerInterface::gc(int $max_lifetime): int|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Wykorzystanie indeksów w większości baz danych to absolutnie podstawa. Ułatwiają one skutecznie znaleźć wiersze pasujące do
kolumny w zapytaniu. Poniżej postaram się wyjaśnić podstawowe zastosowanie indeksów oraz jak prosto można z nich skorzystać.
Załóżmy że w bazie danych mamy tabelę o nazwie "products_in_orders" w której trzymamy informację o produktach w zamówieniu której wycinek wygląda następująco:
order_id
product_id
quantity
price
11243
123
2
10.89
11263
102
1
5.50
11243
102
2
5.50
11250
170
1
8.43
Następnie chcemy wyszukać wszystkie produkty z zamówienia numer 11243 używamy więc zapytania
SELECT * FROM products_in_orders WHERE order_id = 11243
Takie zapytanie zwróci wszystkie wiersze w których znajdzie numer zamówienia 11243 jednak jeżeli w tej tabeli będzie załóżmy 500 000 wierszy potrwa to stosunkowo długo. Przyspieszyć wyszukiwanie można stosując indeks na kolumnie order_id
CREATE INDEX nazwa_indeksu ON products_in_orders (order_id)
Po utworzeniu indeksu natychmiast zaobserwujemy szybsze pobieranie danych, im baza jest większa tym więcej zyskamy.
Na jednej tabeli możemy tworzyć wiele indeksów na każdą kolumnę osobno lub możemy utworzyć jedne indeks na wiele kolumn.
Utwórzmy teraz inne zapytanie (pobierające tylko produkty o określonym id z danego zamówienia):
SELECT * FROM products_in_orders WHERE order_id = 11243 AND product_id = 102
Jeżeli często używamy tego typu zapytań możemy utworzyć indeks na dwóch kolumnach
CREATE INDEX nazwa_indeksu ON products_in_orders (order_id, product_id)
Uwaga!
Można tworzyć dowolną ilość indeksów jednak trzeba pamiętać, że przyśpieszają one wyszukiwanie jednak ich modyfikacja również
zajmuje trochę czasu więc np. dodawania nowych wierszy do bazy będzie troszkę wolniejsze. Używać trzeba ich więc logicznie tylko na kolumnach po których często przeszukujemy dane i na kolumnach które mają dużą różnorodność danych.