PHPHub 迁移数据库文件中 nullable 和索引的问题

数据库字段设置可为null,对索引有性能影响吗?
网上搜到的很多答案都是说有性能影响的,并且不提示设置为null,
文件路径:database/migrateions/2016_07_03_021841_create_users_table.php
内容:

public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('github_id')->index();
            $table->string('github_url');
            $table->string('email')->nullable()->index();
            $table->string('name')->nullable()->index();
            $table->string('login_token')->nullable();
            $table->string('remember_token')->nullable();
            $table->enum('is_banned', ['yes',  'no'])->default('no')->index();
            $table->string('image_url')->nullable();
            $table->integer('topic_count')->default(0)->index();
            $table->integer('reply_count')->default(0)->index();
            $table->integer('follower_count')->default(0)->index();
            $table->string('city')->nullable();
            $table->string('company')->nullable();
            $table->string('twitter_account')->nullable();
            $table->string('personal_website')->nullable();
            $table->string('introduction')->nullable();
            $table->string('certification')->nullable();
            $table->integer('notification_count')->default(0);
            $table->string('github_name')->index();
            $table->string('real_name')->nullable();
            $table->string('linkedin')->nullable();
            $table->string('payment_qrcode')->nullable();
            $table->string('wechat_qrcode')->nullable();
            $table->string('avatar');
            $table->string('login_qr')->nullable();
            $table->string('wechat_openid')->nullable()->index();
            $table->string('wechat_unionid')->nullable()->index();
            $table->string('weibo_name')->nullable();
            $table->string('weibo_link')->nullable();
            $table->boolean('verified')->default(false)->index();
            $table->string('verification_token')->nullable();
            $table->enum('email_notify_enabled', ['yes',  'no'])->default('yes')->index();
            $table->string('register_source')->index();
            $table->timestamp('last_actived_at')->nullable();
            $table->softDeletes();
            $table->timestamps();
        });
    }

这种设置为nullable并建有索引的会有问题吗?

《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 1

没有问题,非null的时候索引效率会比较高一点。

6年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!