{"action":"created","issue":{"url":"https://api.github.com/repos/youtube/vitess/issues/1554","repository_url":"https://api.github.com/repos/youtube/vitess","labels_url":"https://api.github.com/repos/youtube/vitess/issues/1554/labels{/name}","comments_url":"https://api.github.com/repos/youtube/vitess/issues/1554/comments","events_url":"https://api.github.com/repos/youtube/vitess/issues/1554/events","html_url":"https://github.com/youtube/vitess/issues/1554","id":138944549,"number":1554,"title":"How to use a VIndex type \"hash\" in a vschema, need a example of vschema/schema.","user":{"login":"helayzhang","id":3113166,"avatar_url":"https://avatars.githubusercontent.com/u/3113166?v=3","gravatar_id":"","url":"https://api.github.com/users/helayzhang","html_url":"https://github.com/helayzhang","followers_url":"https://api.github.com/users/helayzhang/followers","following_url":"https://api.github.com/users/helayzhang/following{/other_user}","gists_url":"https://api.github.com/users/helayzhang/gists{/gist_id}","starred_url":"https://api.github.com/users/helayzhang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/helayzhang/subscriptions","organizations_url":"https://api.github.com/users/helayzhang/orgs","repos_url":"https://api.github.com/users/helayzhang/repos","events_url":"https://api.github.com/users/helayzhang/events{/privacy}","received_events_url":"https://api.github.com/users/helayzhang/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2016-03-07T10:29:27Z","updated_at":"2016-03-13T13:55:27Z","closed_at":"2016-03-08T03:13:44Z","body":"As I have my own unique key, and want to use it as \"keyspace_id\" for sharding.\r\n\r\nIn example/demo, I see how to create an auto_increase hash key of keyspace. Now I'm seeking the way to use a \"hash\" key:\r\n\r\n>https://github.com/youtube/vitess/blob/master/doc/V3VindexDesign.md\r\nnumeric: binpack a uint64 into a keyspace_id\r\nhash: hashes a uint64 into a keyspace_id\r\nhash_autoinc: Same as hash, but can generate autoincrement values\r\nlookup_hash: Uses a lookup table, and hashes the result to generate a keyspace_id. It’s non-unique.\r\nlookup_hash_unique: lookup_hash, but unique\r\nlookup_hash_autoinc\r\nlookup_hash_unique_autoinc\r\n\r\nFor example, use my own user_id(uint64) which is hashed from a unique key.\r\n\r\nMy testing output:\r\n>WARNING:root:vtclient_exception for None.None.master: ('VitessError', u'execInsertSharded: hash.Create: cannot route query: insert into () values(:): syntax error at position 14', 'Execute', 2, \"insert into tbl_user(keyspace_id, app_id, account, password, nickname, avatar, gender, signature, extern, device, version) values(1, 'appid1', 'user_1', 'pass_1', 'name_1', '', 0, '', '', '', '') /* run this a few times */\", 'tablet_type=master')\r\n\r\nMy config files:\r\n[vschema.zip](https://github.com/youtube/vitess/files/161138/vschema.zip)\r\n\r\nVery appreciated to any help~"},"comment":{"url":"https://api.github.com/repos/youtube/vitess/issues/comments/195961320","html_url":"https://github.com/youtube/vitess/issues/1554#issuecomment-195961320","issue_url":"https://api.github.com/repos/youtube/vitess/issues/1554","id":195961320,"user":{"login":"helayzhang","id":3113166,"avatar_url":"https://avatars.githubusercontent.com/u/3113166?v=3","gravatar_id":"","url":"https://api.github.com/users/helayzhang","html_url":"https://github.com/helayzhang","followers_url":"https://api.github.com/users/helayzhang/followers","following_url":"https://api.github.com/users/helayzhang/following{/other_user}","gists_url":"https://api.github.com/users/helayzhang/gists{/gist_id}","starred_url":"https://api.github.com/users/helayzhang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/helayzhang/subscriptions","organizations_url":"https://api.github.com/users/helayzhang/orgs","repos_url":"https://api.github.com/users/helayzhang/repos","events_url":"https://api.github.com/users/helayzhang/events{/privacy}","received_events_url":"https://api.github.com/users/helayzhang/received_events","type":"User","site_admin":false},"created_at":"2016-03-13T13:55:27Z","updated_at":"2016-03-13T13:55:27Z","body":"Really appreciate your great help and job!\r\nIt is true what you said, and I think using shared foreign key index is for performance considering.\r\nReally useful for me of the details you supply.\r\n\r\nDuring my use of Vitess, I found I often need to restart vtgate progress, that's not good for me.\r\nI often meet this situation:\r\n\r\n1. create a new table of a existing sharded keyspace\r\n2. I do \"ApplySchema\" to the keyspace, to create table.\r\n3. I do \"ReloadSchema\" to every tablet in that keyspace.\r\n4. because that table has a new vindex(often it is a auto-incr id and lookup the keyspace_id, If I don't create a vindex for table, I will get gRPCServerError: error: DML too complex Error when insert), I also need to change my vschema.json. So i do \"ApplyVSchema\" to vtgate.\r\n\r\nAfter all above done, I cannot do a insert to my new table, an error: \"table tbl_test not found\" faised, although I can found the schema by \"GetSchema\" command, checked it is correct. At last, I need restart vtgate, then things will go well.\r\n\r\nIt seems that, if i change vschema, I need to restart vtgate? "}}