From time to time we have to insert a large number of rows into the database, usually because of data import. There are many ways to do it, but the simplest one is to take DbContext, add into the collection, and call SaveChanges. When we use Entity Framework 6 or less, there are a few important rules to follow: Setting context.Configuration.AutoDetectChangesEnabled to false . By default Entity Framework uses change tracker to find all changes made to entities, to generate SQL scripts later. But all we do is make inserts so we know there are no changes, only new rows. There is no need to compare with existing items so change tracker can be disabled. Splitting inserts into batches. If you want to insert 10000 rows into the database, it is better to split them into small batches and call context.SaveChanges() after every n rows where n should be determined experimentally. 100 isn't bad value, but it depends on the size of data. Recreating DbContext after every batch. Even if
Dobra zmiana miała wprowadzić nową jakość, więc postanowiłem przyjrzeć się dokładnie dzisiejszym wiadomościom. Oto krótkie podsumowanie: Na początku mamy zajawki. W pierwszej mowa o zatwierdzonym budżecie i wypowiedź Pana Kuczyńskiego "Minister finansów robił wszystko, aby móc wypełnić obietnice". Wyraźnie słychać, że to nie koniec zdania, ale zajawka się skończyła. Mozna pomyśleć, że minister finansów stara się jak może, ale w sumie nie wiem, bo to nie koniec zdania. Potem kolejna zajawka z Kanclerz Merkel i komentarzem w tle "Walka o przetrwanie". Oglądamy nagranie, na którym jakaś Pani mówi "Słyszałam plotkę, że ma jechać do Chile". Najwyraźniej kanclerz Merkel jest w tak złej sytuacji, że została jej jedynie ucieczka z kraju. Podpowiadam, że w jednym z ostatnich sondaży partia Pani Merkel ma 32,5% poparcia i wygrywa wybory. Źródłem tego sondażu jest wiadomość z portalu wPolityce, którego nie posądzałbym o sprzyjanie Kanclerz Merkel, wrę
Od kilku lat korzystam z hostingu linuxpl.com i zdecydowałem, że czas wyrazić opinię na ten temat. Dla dwóch klientów używałem konta W1GB (około 50 zł na rok, strona + e-mail). Mam też dwa konta W5GB do developmentu i hostowania kilku mniejszych stron, oraz od niedawna konto WPRO, bo oferuje 100GB miejsca. Generalnie polecam, ale mam kilka spostrzeżeń, którymi chciałbym się podzielić: Kontakt z klientem - Odpowiadają na e-maile szybko i raczej są pomocni, chociaż mogliby być bardziej sympatyczni. Gdy PHPMyAdmin chodził wolno z jedną z moich baz, Pan z supportu znalazł przyczynę problemu (bardzo wolno działający widok). Na prośby o zmiany dotyczące konta (wyższy pakiet, włączenie funkcji) reagują szybko. Płatność idzie przez DOTPAY i zaraz po jej wykonaniu następuje reakcje ze strony providera. Uptime Robot pokazuje dostępność na poziomie 99.9% - 100%, więc jest nieźle. Kilkukrotnie doświadczyłem poważniejszych problemów, które trwały nawet kilka godzin, ale byłem w stanie z tym żyć.
Comments
Post a Comment