Category : indexing

I’m needing to get the indexes of a collection in mongodb using laravel, I know that in mongo compass you can use the $ indexStats which returns the indexes, try to replicate the same as follows DB::connection(‘mongodb’)->collection("audience")->timeout(-1)->raw(function($collection){ return $collection->aggregate([ [ ‘$indexStats’ => new stdClass() ] ], ["allowDiskUse" => true]); }); But with a dd () ..

Read more

I’m using: Laravel Framework 8.21.0 10.4.14-MariaDB For a junction table between any two tables, with the above as an example (between the table users and roles), the junction table is created without the one of the foreign key indexes. public function up() { Schema::create(‘user_role’, function (Blueprint $table) { $table->unsignedBigInteger(‘user_id’); $table->foreign(‘user_id’)->references(‘id’)->on(‘users’)->onDelete(‘cascade’); $table->unsignedBigInteger(‘role_id’); $table->foreign(‘role_id’)->references(‘id’)->on(‘roles’)->onDelete(‘cascade’); $table->unique([‘user_id’, ‘role_id’]); }); ..

Read more

$users = DB::table(‘users’)->count(); //dd($users); for($i=0; $i<$users ; $i++){ $updated=DB::table(‘users’)->where(‘latehours’ , 0)->update([‘latehours’=>$total_hours[$i]]); $updated=DB::table(‘users’)->where(‘fine’ , 0)->update([‘fine’=>$fine[$i]]); } I have table named as users I want to update two columns of it latehours and fine respectively, both column are updating but with first value of array’s index, but my loop is not working. arrays are $total_hours and $fine. ..

Read more

<?php namespace AppHttpControllers; use AppHttpControllersController; class SiteController extends Controller{ public $posts = [ 1 => [ ‘title’ => ‘Тайтл страницы 1’, ‘author’ => ‘Автор страницы 1’, ‘dated’ => ‘Дата публикации страницы 1’, ‘teaser’ => ‘Короткое описание страницы 1’, ‘text’ => ‘Полный текст страницы 1’, ], 2 => [ ‘title’ => ‘Тайтл страницы 2’, ‘author’ => ..

Read more

Having the following ids for example TTJ-IP-780 TTJ-IP-730 Typing TTJ- or TTJ-I should return all the records but instead I’m getting back just the first one. Here is my scout config for TNTSearch ‘tntsearch’ => [ ‘storage’ => storage_path(‘indexies’), //place where the index files will be stored ‘fuzziness’ => env(‘TNTSEARCH_FUZZINESS’, true), ‘fuzzy’ => [ ‘prefix_length’ ..

Read more

I’m seeding a CSV file with about 2.000.000 entries into a PostgreSQL database, and some fields need to be dispatched in specific tables with relationship. For the relationship, I’m using this in my migration: $table->foreignId(‘foo_id’)->constrained(‘foos’); When trying to improve the bad seeding performances with PostgreSQL, I realised there’s was no index on the profession_id column, ..

Read more

In Sql server it is posible to buld indexes including columns, like this: CREATE UNIQUE INDEX ix_cust_email_inc ON sales.customers(email) INCLUDE(first_name,last_name); It is posible do something like this in a migration on laravel? At the moment, I can create an index like this, as you see this not does the including magic: $table->index([’email’]); Sourc..

Read more

In SQL server it is possible to build indexes including columns, like this: CREATE UNIQUE INDEX ix_cust_email_inc ON sales.customers(email) INCLUDE(first_name,last_name); It is possible do something like this in a migration on Laravel? At the moment, I can create an index like this, as you see this not have INCLUDE functionality: $table->index([’email’]); Sourc..

Read more