Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Powolne dodawanie indeksu na VARCHAR
cycofiasz
post
Post #1





Grupa: Zarejestrowani
Postów: 711
Pomógł: 127
Dołączył: 5.07.2008
Skąd: Łódź

Ostrzeżenie: (0%)
-----


Witam. Mam tabelę z użytkownikami z ponad 20 mln rekordów. Póki co był tylko jeden indeks na ID (primary key) ale postanowiłem dodać kolejny indeks na pole z nazwą użytkownika - VARCHAR (200) utf8_bin NOT NULL.

Wykonałem z konsoli
  1. ALTER TABLE xx_users ADD INDEX (u_nick);


Od ponad godziny już mieli a nawet jeszcze nie przerobiło 20% całości (sądzę po rozmiarach nowego pliku MYD).
Działam na localhoście. Win XP. Praktycznie zerowe obciążenie pamięci i procesora. Tabela MyISAM.

Czy to normalne? Czy można to jakoś znacznie przyspieszyć, jakieś limity zwiększyć na czas tej operacji?

Go to the top of the page
+Quote Post
wookieb
post
Post #2





Grupa: Moderatorzy
Postów: 8 989
Pomógł: 1550
Dołączył: 8.08.2008
Skąd: Słupsk/Gdańsk




No i trochę to będzie trwać. Dodatkowo Nie używa się już MyIsam...


--------------------
Go to the top of the page
+Quote Post
cycofiasz
post
Post #3





Grupa: Zarejestrowani
Postów: 711
Pomógł: 127
Dołączył: 5.07.2008
Skąd: Łódź

Ostrzeżenie: (0%)
-----


Dlaczego nie? MyIsam ma wszystko czego potrzebuję w tym wypadku i nie widzę powodu by używać innych mechanizmów składowania.
Go to the top of the page
+Quote Post
Crozin
post
Post #4





Grupa: Zarejestrowani
Postów: 6 476
Pomógł: 1306
Dołączył: 6.08.2006
Skąd: Kraków

Ostrzeżenie: (0%)
-----


Jeżeli cechy silnika MyISAM Ci odpowiadają to jak najbardziej powinieneś używać właśnie niego.
Go to the top of the page
+Quote Post
maly_swd
post
Post #5





Grupa: Zarejestrowani
Postów: 744
Pomógł: 118
Dołączył: 14.02.2009
Skąd: poziome

Ostrzeżenie: (0%)
-----


troche mozesz przyspieszyc konfiguracja, pobaw sie tym: (wartosci dodawaj swoje, to jest tylko jakis przyklad z innej strony).


#*** MyISAM Specific options

# The maximum size of the temporary file MySQL is allowed to use while
# recreating the index (during REPAIR, ALTER TABLE or LOAD DATA INFILE.
# If the file-size would be bigger than this, the index will be created
# through the key cache (which is slower).
myisam_max_sort_file_size=100G

# If the temporary file used for fast index creation would be bigger
# than using the key cache by the amount specified here, then prefer the
# key cache method. This is mainly used to force long character keys in
# large tables to use the slower key cache method to create the index.
myisam_sort_buffer_size=8M

# Size of the Key Buffer, used to cache index blocks for MyISAM tables.
# Do not set it larger than 30% of your available memory, as some memory
# is also required by the OS to cache rows. Even if you're not using
# MyISAM tables, you should still set it to 8-64M as it will also be
# used for internal temporary disk tables.
key_buffer_size=262M

# Size of the buffer used for doing full table scans of MyISAM tables.
# Allocated per thread, if a full scan is needed.
read_buffer_size=64K
read_rnd_buffer_size=256K

# This buffer is allocated when MySQL needs to rebuild the index in
# REPAIR, OPTIMZE, ALTER table statements as well as in LOAD DATA INFILE
# into an empty table. It is allocated per thread so be careful with
# large settings.
sort_buffer_size=208K



--------------------
śmieszne obrazki
Kryzys: Ser jem spleśniały, wino piję stare i samochód mam bez dachu..
Go to the top of the page
+Quote Post
cycofiasz
post
Post #6





Grupa: Zarejestrowani
Postów: 711
Pomógł: 127
Dołączył: 5.07.2008
Skąd: Łódź

Ostrzeżenie: (0%)
-----


Dzięki za odpowiedź na temat. Przetestuję różne ustawienia jak tylko skończy mi się indeksować to co już zacząłem winksmiley.jpg
Go to the top of the page
+Quote Post
wookieb
post
Post #7





Grupa: Moderatorzy
Postów: 8 989
Pomógł: 1550
Dołączył: 8.08.2008
Skąd: Słupsk/Gdańsk




Nie używam MyIsam z tego prostego względu, że klucze czasem po prostu się wywalają. Nie raz zdażyło mi się widzieć BRAK MOCY indeksu na tabelach MyIsam po prostu "tak se". Dlatego ostatecznie odszedłem od tego silnika tabel.


--------------------
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 19.08.2025 - 02:12